From: ginkgoMZD Date: Tue, 20 Dec 2022 15:52:58 +0000 (-0500) Subject: correctly handle empty arrays in custom-fields; X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=04333740043a724d79867ab00412b48d6712b3de;p=civicrm-core.git correctly handle empty arrays in custom-fields; --- diff --git a/api/v3/utils.php b/api/v3/utils.php index b4b5611269..2a03f8e4a7 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -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); } @@ -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)) {