X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FOptionGroup.php;h=0b76228f1c1c9a8bbd47f389fa027de8f11bbcee;hb=752a3cbc3fd578e398ccd3773cc83b93c28805d8;hp=059a5bf878604fab3bc2c7cac65c7e145490efae;hpb=3ad5c6019923f2d95fcc3d143764cbc89ec8bb4e;p=civicrm-core.git diff --git a/CRM/Admin/Form/OptionGroup.php b/CRM/Admin/Form/OptionGroup.php index 059a5bf878..0b76228f1c 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -78,7 +78,7 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description') ); - $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE); + $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), empty($this->_values['is_reserved'])); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { @@ -96,8 +96,12 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { $element->freeze(); } } + + $this->add('checkbox', 'is_reserved', ts('Reserved?')); + $this->freeze('is_reserved'); + if (!empty($this->_values['is_reserved'])) { - $this->freeze(array('name', 'is_active')); + $this->freeze(array('name', 'is_active', 'data_type')); } } @@ -110,22 +114,25 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { public function postProcess() { CRM_Utils_System::flushCache(); - $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::DELETE) { CRM_Core_BAO_OptionGroup::del($this->_id); CRM_Core_Session::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success'); } else { - - $params = $ids = array(); // store the submitted values in an array $params = $this->exportValues(); - if ($this->_action & CRM_Core_Action::UPDATE) { - $ids['optionGroup'] = $this->_id; + if ($this->_action & CRM_Core_Action::ADD) { + // If we are adding option group via UI it should not be marked reserved. + if (!isset($params['is_reserved'])) { + $params['is_reserved'] = 0; + } + } + elseif ($this->_action & CRM_Core_Action::UPDATE) { + $params['id'] = $this->_id; } - $optionGroup = CRM_Core_BAO_OptionGroup::add($params, $ids); + $optionGroup = CRM_Core_BAO_OptionGroup::add($params); CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name)), ts('Saved'), 'success'); } }