Merge pull request #19354 from demeritcowboy/php74-more-more
[civicrm-core.git] / CRM / Custom / Form / Option.php
index 05f6dcd81e72784dffd4ce024dbd224208efef91..e392a9af7dd5a7e544f1665c7feab676cdcc73d8 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,
@@ -397,7 +397,6 @@ SELECT count(*)
     $oldWeight = NULL;
     if ($this->_id) {
       $customOption->id = $this->_id;
-      CRM_Core_BAO_CustomOption::updateCustomValues($params);
       $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id');
     }
     else {
@@ -420,7 +419,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(
@@ -483,6 +483,9 @@ SELECT count(*)
       }
     }
 
+    if ($this->_id) {
+      CRM_Core_BAO_CustomOption::updateValue($customOption->id, $customOption->value);
+    }
     $customOption->save();
 
     $msg = ts('Your multiple choice option \'%1\' has been saved', [1 => $customOption->label]);