Skip to content

Commit

Permalink
correctly handle empty arrays in custom-fields;
Browse files Browse the repository at this point in the history
  • Loading branch information
ginkgomzd committed Dec 20, 2022
1 parent 870e748 commit 0433374
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 @@ -1100,7 +1100,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 @@ -1170,6 +1170,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 0433374

Please sign in to comment.