Merge pull request #21578 from civicrm/5.42
[civicrm-core.git] / CRM / Core / Form.php
index 69fc4ccb62bee3b83637c3651d8a1e1d771b8578..e139e04262dfafda8b067e5c4ae6608b959edf39 100644 (file)
@@ -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;
   }
 
   /**