ensure custom field checkboxes are populated in profiles
authorJamie McClelland <jm@mayfirst.org>
Tue, 9 Jun 2020 19:37:19 +0000 (15:37 -0400)
committereileen <emcnaughton@wikimedia.org>
Mon, 27 Jul 2020 10:39:18 +0000 (22:39 +1200)
CRM/Core/BAO/UFGroup.php

index b4e01738ca17c70ce1f34684e0e0e21802276d10..34490de330646be9af9eb12d06d5bdf8a2aa1a3a 100644 (file)
@@ -2326,6 +2326,14 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
           }
           elseif (CRM_Core_BAO_CustomField::getKeyID($name)) {
             $defaults[$fldName] = self::formatCustomValue($field, $details[$name]);
+            if (!$singleProfile && $field['html_type'] === 'CheckBox') {
+              // For batch update profile there needs to be a key lik
+              // $defaults['field[166]['custom_8'][2]'] => 1 where
+              // 166 is the conntact id, 8 is the field id and 2 is the checkbox option.
+              foreach ($defaults[$fldName] as $itemKey => $itemValue) {
+                $defaults[$fldName . '[' . $itemKey . ']'] = $itemValue;
+              }
+            }
           }
           else {
             $defaults[$fldName] = $details[$name];
@@ -3585,6 +3593,7 @@ SELECT  group_id
     if (CRM_Core_BAO_CustomField::isSerialized($field)) {
       $value = CRM_Utils_Array::explodePadded($value);
 
+      // This may not be required now.
       if ($field['html_type'] === 'CheckBox') {
         $checkboxes = [];
         foreach (array_filter($value) as $item) {