Skip to content

Commit

Permalink
correct logic for handling empty-array values for checkboxes;
Browse files Browse the repository at this point in the history
  • Loading branch information
ginkgomzd committed Apr 26, 2022
1 parent 6de1f67 commit 0f6e4e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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) {
list($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 @@ -1178,7 +1178,7 @@ function formatCheckBoxField(&$checkboxFieldValue, $customFieldLabel, $entity) {

$options = $options['values'];
$validValue = TRUE;
if (is_array($checkboxFieldValue)) {
if (is_array($checkboxFieldValue) && !empty($checkboxFieldValue)) {
foreach ($checkboxFieldValue as $key => $value) {
if (!array_key_exists($key, $options)) {
$validValue = FALSE;
Expand Down

0 comments on commit 0f6e4e4

Please sign in to comment.