CRM-12021 - Don't allow no default location type
authorColeman Watts <coleman@civicrm.org>
Fri, 7 Aug 2015 18:43:50 +0000 (14:43 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 7 Aug 2015 18:43:50 +0000 (14:43 -0400)
CRM/Admin/Form/LocationType.php

index 6fd84846d6ac95a794abbb3deee3d1c0af49ad72..7d7f01f0804ba6969c9a4fccbe52d5950931b745 100644 (file)
@@ -76,8 +76,14 @@ class CRM_Admin_Form_LocationType extends CRM_Admin_Form {
 
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_default', ts('Default?'));
-    if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_reserved')) {
-      $this->freeze(array('name', 'description', 'is_active'));
+
+    if ($this->_action & CRM_Core_Action::UPDATE) {
+      if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_reserved')) {
+        $this->freeze(array('name', 'description', 'is_active'));
+      }
+      if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_default')) {
+        $this->freeze(array('is_default'));
+      }
     }
   }