dev/core#4152 Fix custom data code to not cast to a float
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Mar 2023 03:45:53 +0000 (16:45 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Mar 2023 04:52:11 +0000 (17:52 +1300)
begin adding support for locale-formatted number input in custom fields

CRM/Core/BAO/CustomGroup.php

index 3615f2271f827daaade82d95099d909043d026d9..50aeb3dea2c54544ec3a79c0c4f09b328bbbad39 100644 (file)
@@ -1431,11 +1431,17 @@ ORDER BY civicrm_custom_group.weight,
             }
           }
           else {
-            if ($field['data_type'] == "Float") {
-              $defaults[$elementName] = (float) $value;
+            if ($field['data_type'] === 'Float') {
+              if ($field['html_type'] === 'Text') {
+                $defaults[$elementName] = CRM_Utils_Number::formatLocaleNumeric($value);
+              }
+              else {
+                // This casting came in from svn & may not be right.
+                $defaults[$elementName] = (float) $value;
+              }
             }
-            elseif ($field['data_type'] == 'Money' &&
-              $field['html_type'] == 'Text'
+            elseif ($field['data_type'] === 'Money' &&
+              $field['html_type'] === 'Text'
             ) {
               $defaults[$elementName] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($value);
             }