Fix saving of State/Province Multi-select values
authorChristian Wach <needle@haystack.co.uk>
Thu, 2 Jul 2020 14:39:24 +0000 (15:39 +0100)
committerChristian Wach <needle@haystack.co.uk>
Thu, 2 Jul 2020 14:39:24 +0000 (15:39 +0100)
CRM/Core/BAO/CustomGroup.php

index fa57ff1561b8513c3eec4d79e4f90a5b55f13c55..81738e34250c48ee31db44191ec28bcca3357402 100644 (file)
@@ -1361,6 +1361,7 @@ ORDER BY civicrm_custom_group.weight,
                 }
               }
               else {
+                // Values may be "array strings" or actual arrays. Handle both.
                 if (is_array($value) && count($value)) {
                   CRM_Utils_Array::formatArrayKeys($value);
                   $checkedValue = $value;
@@ -1383,7 +1384,14 @@ ORDER BY civicrm_custom_group.weight,
           }
           else {
             if (isset($value)) {
-              $checkedValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
+              // Values may be "array strings" or actual arrays. Handle both.
+              if (is_array($value) && count($value)) {
+                CRM_Utils_Array::formatArrayKeys($value);
+                $checkedValue = $value;
+              }
+              else {
+                $checkedValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($value, 1, -1));
+              }
               foreach ($checkedValue as $val) {
                 if ($val) {
                   $defaults[$elementName][$val] = $val;