Display bug for Checkboxes Custom field on Event Confirm / Thank you pages
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Author Developer
After digging, the form is passing the submitted $value as something like :
[1 => 0, 2 => 1, 3 => 1]
The "1" is only a boolean but it is interpreted as a checkbox value ($val) in https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/CustomField.php#L1252 (function displayValue) :
... elseif (is_array($value)) { $v = array(); foreach ($value as $key => $val) { $v[] = CRM_Utils_Array::value($val, $field['options']); } $display = implode(', ', $v); } ...
Not sure if we should change this function or the one that send the params in the first place...
- Author Developer
Patch that fix the bug but not with a good level of confidence as there is a good chance that it creates regressions somewhere else :
--- a/sites/all/modules/civicrm/CRM/Core/BAO/CustomField.php +++ b/sites/all/modules/civicrm/CRM/Core/BAO/CustomField.php @@ -1241,11 +1241,20 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $display = $value; } } - elseif (is_array($value)) { + elseif (is_array($value)) { $v = array(); - foreach ($value as $key => $val) { - $v[] = CRM_Utils_Array::value($val, $field['options']); - } + if ($field['html_type'] == 'CheckBox') { + foreach ($value as $key => $val) { + if ($val == 1) { + $v[] = CRM_Utils_Array::value($key, $field['options']); + } + } + } + else { + foreach ($value as $key => $val) { + $v[] = CRM_Utils_Array::value($val, $field['options']); + } + } $display = implode(', ', $v); } else {
- Author Developer
Somewhat related : #866 (closed)
- Author Developer
As expected, the patch #1058 (comment 19248) is pretty much breaking everything else (participant display, report, ...) so we probably need to fix the data provided to the function instead.
- jaapjansma added ~84 needs:concept approval sig:bug triaged labels
added ~84 needs:concept approval sig:bug triaged labels
- Author Developer
I have created a PR that doesn't seem to break anything : https://github.com/civicrm/civicrm-core/pull/14587
- eileen added Concept approved label and removed needs:concept approval label
added Concept approved label and removed needs:concept approval label
- eileen closed
closed
- justinfreeman (Agileware) mentioned in issue #1089 (closed)
mentioned in issue #1089 (closed)
- Developer
Thanks for fixing this one!
- JonGold mentioned in issue #1099 (closed)
mentioned in issue #1099 (closed)