From b4afac658a40c6d9759751d59651bf33156ee279 Mon Sep 17 00:00:00 2001 From: Christian Wach Date: Thu, 2 Jul 2020 15:39:24 +0100 Subject: [PATCH] Fix saving of State/Province Multi-select values --- CRM/Core/BAO/CustomGroup.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index fa57ff1561..81738e3425 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -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; -- 2.25.1