Skip to content

Commit

Permalink
BTHAB-207: Do not attempt to format custom value of empty string
Browse files Browse the repository at this point in the history
Included in - PR: civicrm#25451
  • Loading branch information
olayiwola-compucorp committed Oct 20, 2023
1 parent 1dfcbe8 commit 6aa4783
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CRM/Core/BAO/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1264,19 +1264,21 @@ private static function formatDisplayValue($value, $field, $entityId = NULL) {
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;
}
Expand Down

0 comments on commit 6aa4783

Please sign in to comment.