From 2716c6321837cd7e05fa1c050bf0f59b571c769c Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 8 Feb 2024 09:05:17 +1300 Subject: [PATCH] dev/core#4973 Fix credit card info not showing up in ThankYou & Confirm --- CRM/Event/Form/Registration.php | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 6a5cff960f..e31f111abb 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -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. * -- 2.25.1