Пример #1
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     CRM_Utils_System::setTitle(ts('Dropdown Options'));
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
     $this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title'));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
     $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE);
     $element = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($this->_action & CRM_Core_Action::UPDATE) {
         if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
             static $caseCount = NULL;
             if (!isset($caseCount)) {
                 $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
             }
             if ($caseCount > 0) {
                 $element->freeze();
             }
         }
         if (!empty($this->_values['is_reserved'])) {
             $this->freeze(array('name', 'is_active'));
         }
     }
     $this->assign('id', $this->_id);
 }