From 34a9221c86a2d4146d038a02e99070c45e139b75 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Sep 2021 09:44:27 +1200 Subject: [PATCH] dev/core#2493 Add support for money fields to This ensures that any money fields retrieved by are in a machine usable format. We've been switching to this function rather than 'passing around arrays' but we need to ensure this function is returning clean money to prevent regressions. --- CRM/Core/Form.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 69fc4ccb62..e139e04262 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -70,6 +70,16 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ public $_action; + /** + * Monetary fields that may be submitted. + * + * Any fields in this list will be converted to non-localised format + * if retrieved by `getSubmittedValue` + * + * @var array + */ + protected $submittableMoneyFields = []; + /** * Available payment processors. * @@ -2746,7 +2756,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page { if (empty($this->exportedValues)) { $this->exportedValues = $this->controller->exportValues($this->_name); } - return $this->exportedValues[$fieldName] ?? NULL; + $value = $this->exportedValues[$fieldName] ?? NULL; + if (in_array($fieldName, $this->submittableMoneyFields, TRUE)) { + return CRM_Utils_Rule::cleanMoney($value); + } + return $value; } /** -- 2.25.1