dev/core#1974 Fix incorrect handling of serialize key when changing custom field...
authoreileen <emcnaughton@wikimedia.org>
Fri, 28 Aug 2020 02:06:57 +0000 (14:06 +1200)
committereileen <emcnaughton@wikimedia.org>
Fri, 28 Aug 2020 02:07:00 +0000 (14:07 +1200)
See https://lab.civicrm.org/dev/core/-/issues/1974

CRM/Custom/Form/ChangeFieldType.php

index a47e75c4cdf7561098153c9d65e54dc4683d30e7..24650919ae6cd35ae29fa2268fbb2fd6c16ea1af 100644 (file)
@@ -146,13 +146,14 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
     $customField = new CRM_Core_DAO_CustomField();
     $customField->id = $this->_id;
     $customField->find(TRUE);
+    $customField->serialize = in_array($dstHtmlType, $mutliValueOps, TRUE);
 
     if ($dstHtmlType == 'Text' && in_array($srcHtmlType, [
       'Select',
       'Radio',
       'Autocomplete-Select',
     ])) {
-      $customField->option_group_id = "NULL";
+      $customField->option_group_id = 'NULL';
       CRM_Core_BAO_CustomField::checkOptionGroup($this->_values['option_group_id']);
     }
 
@@ -165,7 +166,7 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
       $this->firstValueToFlatten($tableName, $this->_values['column_name']);
     }
 
-    $customField->html_type = $dstHtmlType;
+    $customField->html_type = ($dstHtmlType === 'Multi-Select') ? 'Select' : $dstHtmlType;
     $customField->save();
 
     // Reset cache for custom fields