dev/core#4973 Fix credit card info not showing up in ThankYou & Confirm
authoreileen <emcnaughton@wikimedia.org>
Wed, 7 Feb 2024 20:05:17 +0000 (09:05 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 7 Feb 2024 20:06:30 +0000 (09:06 +1300)
CRM/Event/Form/Registration.php

index 6a5cff960fb36d31f037d67a8bba1fc0eb819882..e31f111abbb59893b7b306e558b74514577c3100 100644 (file)
@@ -1362,6 +1362,40 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
     return $errors;
   }
 
+  /**
+   * Get the submitted value, accessing it from whatever form in the flow it is
+   * submitted on.
+   *
+   * @todo support AdditionalParticipant forms too.
+   *
+   * @param string $fieldName
+   *
+   * @return mixed|null
+   */
+  public function getSubmittedValue(string $fieldName) {
+    $value = parent::getSubmittedValue($fieldName);
+    // Check for value as well in case the field has been added to the Confirm form
+    // I don't quite know how that works but something Matt has worked on.
+    if ($value || !in_array($this->getName(), ['Confirm', 'ThankYou'], TRUE)) {
+      return $value;
+    }
+    // If we are on the Confirm or ThankYou page then the submitted values
+    // were on the Register Page so we return them
+    $value = $this->controller->exportValue('Register', $fieldName);
+    if (in_array($fieldName, $this->submittableMoneyFields, TRUE)) {
+      return CRM_Utils_Rule::cleanMoney($value);
+    }
+
+    // Numeric fields are not in submittableMoneyFields (for now)
+    $fieldRules = $this->_rules[$fieldName] ?? [];
+    foreach ($fieldRules as $rule) {
+      if ('money' === $rule['type']) {
+        return CRM_Utils_Rule::cleanMoney($value);
+      }
+    }
+    return $value;
+  }
+
   /**
    * Set the first participant ID if not set.
    *