dev/core#2139 fix defaulting for multi-select custom fields
authorAlice Frumin <alice@aghstrategies.com>
Mon, 2 Nov 2020 18:56:51 +0000 (12:56 -0600)
committerAlice Frumin <alice@aghstrategies.com>
Mon, 2 Nov 2020 18:56:51 +0000 (12:56 -0600)
CRM/Core/BAO/CustomOption.php
CRM/Custom/Form/Option.php

index e876436f75ff03a34da1d192348282ea46563921..cb20ec185b66d3a6589810aa68fe690310a9e8ee 100644 (file)
@@ -137,7 +137,7 @@ class CRM_Core_BAO_CustomOption {
         $action -= CRM_Core_Action::DELETE;
       }
 
-      if (in_array($field->html_type, ['CheckBox', 'Multi-Select'])) {
+      if ($field->html_type == 'CheckBox' || ($field->html_type == 'Select' && $field->serialize == 1)) {
         $options[$dao->id]['is_default'] = (isset($defVal) && in_array($dao->value, $defVal));
       }
       else {
index 05f6dcd81e72784dffd4ce024dbd224208efef91..7b4441074c33b565d959456f3990476fdd34bb06 100644 (file)
@@ -95,9 +95,9 @@ class CRM_Custom_Form_Option extends CRM_Core_Form {
 
       $paramsField = ['id' => $this->_fid];
       CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
-
       if ($fieldDefaults['html_type'] == 'CheckBox'
-        || $fieldDefaults['html_type'] == 'Multi-Select'
+        // Multi-Select
+        || ($fieldDefaults['html_type'] == 'Select' && $fieldDefaults['serialize'] == 1)
       ) {
         if (!empty($fieldDefaults['default_value'])) {
           $defaultCheckValues = explode(CRM_Core_DAO::VALUE_SEPARATOR,
@@ -420,7 +420,8 @@ SELECT count(*)
       $customField->find(TRUE) &&
       (
         $customField->html_type == 'CheckBox' ||
-        $customField->html_type == 'Multi-Select'
+        // Multi Value Select
+        ($customField->html_type == 'Select' && $customField->serialize == 1)
       )
     ) {
       $defVal = explode(