CRM-13704 - Fatal error prevents deletion of options from custom fields
authorDonald A. Lobo <lobo@civicrm.org>
Tue, 5 Nov 2013 17:57:10 +0000 (09:57 -0800)
committerDonald A. Lobo <lobo@civicrm.org>
Tue, 5 Nov 2013 17:57:10 +0000 (09:57 -0800)
http://issues.civicrm.org/jira/browse/CRM-13704

CRM/Custom/Form/Option.php

index 1963d467f567e0c66a569684b348e6e2bb5261e1..d43a974f177a5fe6dbca0e80a8d3bf4204e018a3 100644 (file)
@@ -80,22 +80,26 @@ class CRM_Custom_Form_Option extends CRM_Core_Form {
 
     $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
 
-    if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
-      CRM_Core_Error::fatal("You cannot add or edit muliple choice options in a reserved custom field-set.");
-    }
     if (!isset($this->_gid) && $this->_fid) {
-      $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
+      $this->_gid = CRM_Core_DAO::getFieldValue(
+        'CRM_Core_DAO_CustomField',
         $this->_fid,
         'custom_group_id'
       );
     }
+
     if ($this->_fid) {
-      $this->_optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
+      $this->_optionGroupID = CRM_Core_DAO::getFieldValue(
+        'CRM_Core_DAO_CustomField',
         $this->_fid,
         'option_group_id'
       );
     }
 
+    if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
+      CRM_Core_Error::fatal("You cannot add or edit muliple choice options in a reserved custom field-set.");
+    }
+
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
   }