Skip to content
Snippets Groups Projects
Unverified Commit 129c0d01 authored by DaveD's avatar DaveD Committed by GitHub
Browse files

Merge pull request #25451 from eileenmcnaughton/num

Do not attempt to format custom value of empty string
parents 5d312c36 97f9a5f3
Branches
Tags
No related merge requests found
......@@ -1129,6 +1129,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
* @param int|null $entityId
*
* @return string
* @throws \Brick\Money\Exception\UnknownCurrencyException
*/
private static function formatDisplayValue($value, $field, $entityId = NULL) {
......@@ -1269,19 +1270,21 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
break;
case 'Text':
if ($field['data_type'] == 'Money' && isset($value)) {
if ($field['data_type'] === 'Money' && isset($value)) {
// $value can also be an array(while using IN operator from search builder or api).
$values = [];
foreach ((array) $value as $val) {
$disp[] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($val);
$values[] = $val === '' ? '' : CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($val);
}
$display = implode(', ', $disp);
$display = implode(', ', $values);
}
elseif ($field['data_type'] == 'Float' && isset($value)) {
elseif ($field['data_type'] === 'Float' && isset($value)) {
// $value can also be an array(while using IN operator from search builder or api).
$values = [];
foreach ((array) $value as $val) {
$disp[] = CRM_Utils_Number::formatLocaleNumeric($val);
$values[] = $val === '' ? '' : CRM_Utils_Number::formatLocaleNumeric($val);
}
$display = implode(', ', $disp);
$display = implode(', ', $values);
}
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment