From 04333740043a724d79867ab00412b48d6712b3de Mon Sep 17 00:00:00 2001 From: ginkgoMZD Date: Tue, 20 Dec 2022 10:52:58 -0500 Subject: [PATCH] correctly handle empty arrays in custom-fields; --- api/v3/utils.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index b4b561126971..2a03f8e4a7cb 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)) {