}
else {
$display = CRM_Utils_Array::value($value, $field['options'], '');
+ // For float type (see Number and Money) $value would be decimal like
+ // 1.00 (because it is stored in db as decimal), while options array
+ // key would be integer like 1. In this case expression on line above
+ // would return empty string (default value), despite the fact that
+ // matching option exists in the array.
+ // In such cases we could just get intval($value) and fetch matching
+ // option again, but this would not work if key is float like 5.6.
+ // So we need to truncate trailing zeros to make it work as expected.
+ if ($display === '' && strpos($value, '.') !== FALSE) {
+ // Use round() to truncate trailing zeros, e.g:
+ // 10.00 -> 10, 10.60 -> 10.6, 10.69 -> 10.69.
+ $value = (string) round($value, 5);
+ $display = $field['options'][$value] ?? '';
+ }
}
break;