'Emails', self::FIELD_TYPE_TEXT => 'Text', self::FIELD_TYPE_HTML_EDITOR => 'HtmlEditor', self::FIELD_TYPE_NUMERIC => 'Numeric', self::FIELD_TYPE_HEADER => 'Header' ); protected $_controllerAction = 'insert'; protected $_defaults = array('enabled' => 'y'); public function init() { $this->_defaults['idCategory'] = \Qs_Request::getGetValue('idCategory'); return parent::init(); } protected function _initElements() { $dataObj = new Admin\Obj(); $this->addElement( 'text', 'newName', array('label' => 'Name', 'required' => true, 'value' => $this->_getData('name')) ); $this->addElement( 'select', 'idCategory', array( 'label' => 'Category', 'required' => true, 'multiOptions' => array('' => 'Select Category') + $dataObj->getSettingsCategory4Select() ) ); $this->addElement( 'select', 'fieldType', array( 'label' => 'Field Type', 'required' => true, 'multiOptions' => array('' => 'Select Field Type') + $this->_fieldTypeArray ) ); $this->addElement('text', 'label', array('label' => 'Label')); $this->addElement( 'textarea', 'value', array('label' => 'Value', 'rows' => 5) ); $this->addElement('text', 'options', array('label' => 'Options')); $this->addElement( 'textarea', 'description', array('label' => 'Description', 'rows' => 3) ); $this->addElement('checkbox', 'required', array('label' => 'Required', 'decoration' => 'simple')); $this->addElement('checkbox', 'system', array('label' => 'system', 'decoration' => 'simple')); $this->addElement( 'grid', 'settingOptions', array( 'label' => 'Setting Options', 'columns' => array( 'variable' => array( 'type' => 'text', 'title' => 'Variable', ), 'value' => array( 'type' => 'text', 'title' => 'Value', ), 'type' => array( 'type' => 'select', 'title' => 'Type', 'multiOptions' => array('string' => 'String', 'int' => 'Int') ), '_options' => array('type' => 'options', 'title' => '') ) ) ); $this->addFormRule(array($this, 'validateForm')); return $this; } public function validateForm($data) { $errors = array(); if ($data['name'] != $data['newName']) { $dataObj = new Admin\Obj(); $dataObj->setPrimaryKey($data['newName']); $otherField = $dataObj->getData(); if (!empty($otherField)) { $errors['newName'] = 'Name must be unique'; }; } return (empty($errors)) ? true : $errors; } public function render(\Zend_View_Interface $view = null) { /** @var $doc \App_Doc_Site */ $doc = \Zend_Registry::get('doc'); $ckeditorBasePath = addslashes(\Qs_Constant::get('BASE_URL') . '/js/ckeditor/'); $doc->addInlineScript( 'CKEDITOR_BASEPATH', 'window.CKEDITOR_BASEPATH = "' . $ckeditorBasePath . '"', array('beforeScripts' => true) ); $doc->addScript('js/ckeditor/ckeditor.js'); $doc->addScript('js/app/settings/field.js'); $doc->addInitObject('App_Settings_New', array(array( 'id' => 'value', 'mode' => 'edit', 'config' => array( 'toolbar' => 'Default', 'height' => 250, 'contentsCss' => '/Quick_Site_Framework/trunk/www/css/ckeditor.css' ) ))); return parent::render($view); } }