Skip to content

Commit

Permalink
CIVIIB-122: Correctly handle empty arrays in custom-fields
Browse files Browse the repository at this point in the history
Included in CiviCRM 5.58.0
PR: civicrm#23305
  • Loading branch information
ginkgomzd authored and erawat committed Apr 12, 2023
1 parent 84ecc1c commit 6acad4d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/v3/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ function _civicrm_api3_custom_format_params($params, &$values, $extends, $entity
foreach ($params as $key => $value) {
[$customFieldID, $customValueID] = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
if ($customFieldID && (!is_null($value))) {
if ($checkCheckBoxField && !empty($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') {
if ($checkCheckBoxField && isset($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') {
formatCheckBoxField($value, 'custom_' . $customFieldID, $entity);
}

Expand Down Expand Up @@ -1180,6 +1180,10 @@ function formatCheckBoxField(&$checkboxFieldValue, $customFieldLabel, $entity) {
return;
}

if (is_array($checkboxFieldValue) && empty($checkboxFieldValue)) {
$checkboxFieldValue = '';
return;
}
$options = $options['values'];
$validValue = TRUE;
if (is_array($checkboxFieldValue)) {
Expand Down

0 comments on commit 6acad4d

Please sign in to comment.