Skip to content

Commit

Permalink
Merge pull request #23305 from ginkgomzd/custom-empty-array
Browse files Browse the repository at this point in the history
correct logic for handling empty-array values for checkboxes;
  • Loading branch information
demeritcowboy authored Dec 20, 2022
2 parents 033a14c + 0433374 commit 666f848
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 666f848

Please sign in to comment.