From e30142ba5c946bde8cfaf5418aa1670dfdbf0dd6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 3 Apr 2020 13:00:58 -0400 Subject: [PATCH] CustomField - switch statement to use data_type instead of html_type --- CRM/Core/BAO/CustomGroup.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 3a9828f0c9..4dc6d36f3f 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1316,10 +1316,10 @@ ORDER BY civicrm_custom_group.weight, } $elementName = $field['element_name']; + $serialize = CRM_Core_BAO_CustomField::isSerialized($field); - switch ($field['html_type']) { - case 'Multi-Select': - case 'CheckBox': + if ($serialize) { + if ($field['data_type'] != 'Country' && $field['data_type'] != 'StateProvince') { $defaults[$elementName] = []; $customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded); if ($viewMode) { @@ -1377,10 +1377,8 @@ ORDER BY civicrm_custom_group.weight, } } } - break; - - case 'Multi-Select Country': - case 'Multi-Select State/Province': + } + else { if (isset($value)) { $checkedValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); foreach ($checkedValue as $val) { @@ -1389,9 +1387,10 @@ ORDER BY civicrm_custom_group.weight, } } } - break; - - case 'Select Country': + } + } + else { + if ($field['data_type'] == 'Country') { if ($value) { $defaults[$elementName] = $value; } @@ -1399,9 +1398,8 @@ ORDER BY civicrm_custom_group.weight, $config = CRM_Core_Config::singleton(); $defaults[$elementName] = $config->defaultContactCountry; } - break; - - default: + } + else { if ($field['data_type'] == "Float") { $defaults[$elementName] = (float) $value; } @@ -1413,6 +1411,7 @@ ORDER BY civicrm_custom_group.weight, else { $defaults[$elementName] = $value; } + } } } } -- 2.25.1