From 44448aa520898ee808b65f0dd2a9a90a2290b3e5 Mon Sep 17 00:00:00 2001 From: Vangelis Pantazis Date: Wed, 2 Oct 2019 12:19:29 +0200 Subject: [PATCH] Takes care of customfields of type multiselect that were not being rendered. --- CRM/Core/BAO/UFGroup.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index c3974fbdd7..81da36391d 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2479,7 +2479,39 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) elseif (substr($fieldName, 0, 14) === 'address_custom' && CRM_Utils_Array::value(substr($fieldName, 8), $value) ) { - $defaults[$fldName] = $value[substr($fieldName, 8)]; + if (isset($fields[$name]['html_type'])) { + switch ($fields[$name]['html_type']) { + case 'Multi-Select State/Province': + case 'Multi-Select Country': + case 'Multi-Select': + $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value[substr($fieldName, 8)]); + foreach ($v as $item) { + if ($item) { + $defaults[$fldName][$item] = $item; + } + } + break; + + case 'CheckBox': + $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value[substr($fieldName, 8)]); + foreach ($v as $item) { + if ($item) { + $defaults[$fldName][$item] = 1; + // seems like we need this for QF style checkboxes in profile where its multiindexed + // CRM-2969 + $defaults["{$fldName}[{$item}]"] = 1; + } + } + break; + + default: + $defaults[$fldName] = $value[substr($fieldName, 8)]; + break; + } + } + else { + $defaults[$fldName] = $value[substr($fieldName, 8)]; + } } } } -- 2.25.1