Fix for issue editing custom fields with option groups after #12423
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Wed, 22 Aug 2018 21:55:10 +0000 (22:55 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Wed, 22 Aug 2018 22:00:53 +0000 (23:00 +0100)
CRM/Custom/Form/Field.php

index 014ae6ad6e0e1a8e709a729efcc278498c45df70..0a83a5b37ea99e7a2ffaf9af3a2742b999c046da 100644 (file)
@@ -319,15 +319,21 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
       $this->freeze('data_type');
     }
 
-    $optionGroupParams = [
-      'is_reserved' => 0,
-      'is_active' => 1,
-      'options' => ['limit' => 0, 'sort' => "title ASC"],
-      'return' => ['title'],
-    ];
     if ($this->_action == CRM_Core_Action::UPDATE) {
-      $optionGroupParams['id'] = $this->_values['id'];
+      $optionGroupParams = [
+        'id' => $this->_values['option_group_id'],
+        'return' => ['title'],
+      ];
     }
+    else {
+      $optionGroupParams = [
+        'is_reserved' => 0,
+        'is_active' => 1,
+        'options' => ['limit' => 0, 'sort' => "title ASC"],
+        'return' => ['title'],
+      ];
+    }
+
     // Get all custom (is_reserved=0) option groups
     $optionGroupMetadata = civicrm_api3('OptionGroup', 'get', $optionGroupParams);