'Emails', self::FIELD_TYPE_TEXT => 'Text', self::FIELD_TYPE_TEXTAREA => 'Textarea', self::FIELD_TYPE_HTML_EDITOR => 'HtmlEditor', self::FIELD_TYPE_NUMERIC => 'Numeric', self::FIELD_TYPE_HEADER => 'Header', self::FIELD_TYPE_RADIO => 'Radio', ]; protected $_controllerAction = 'insert'; protected $_defaults = ['enabled' => 'y']; public function init() { if (empty($this->_defaults['idCategory'])) { $this->_defaults['idCategory'] = \Qs_Request::getRequestValue('idCategory'); } return parent::init(); } protected function _initElements() { $dataObj = new Admin\Obj(); $this->addElement( 'text', 'newName', ['label' => 'Name', 'required' => true, 'value' => $this->_getData('name')] ); $this->addElement( 'select', 'idCategory', [ 'label' => 'Category', 'required' => true, 'multiOptions' => ['' => 'Select Category'] + $dataObj->getSettingsCategory4Select(), ] ); $this->addElement('text', 'fieldType', ['label' => 'Field Type', 'required' => true]); $this->addElement('text', 'label', ['label' => 'Label']); $this->addElement( 'textarea', 'value', ['label' => 'Value', 'rows' => 5] ); $this->addElement('text', 'options', ['label' => 'Options']); $this->addElement( 'textarea', 'description', ['label' => 'Description', 'rows' => 3] ); $this->addElement('checkbox', 'required', ['label' => 'Required', 'decoration' => 'simple']); $this->addElement('checkbox', 'system', ['label' => 'system', 'decoration' => 'simple']); $this->addElement( 'grid', 'settingOptions', [ 'label' => 'Options', 'columns' => [ 'variable' => [ 'type' => 'text', 'title' => 'Variable', ], 'value' => [ 'type' => 'text', 'title' => 'Value', ], 'type' => [ 'type' => 'select', 'title' => 'Type', 'multiOptions' => ['string' => 'String', 'int' => 'Int'], ], '_options' => ['type' => 'options', 'title' => ''], ], ] ); $this->addFormRule([$this, 'validateForm']); return $this; } public function validateForm($data) { $errors = []; 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 . '"', ['beforeScripts' => true] ); $doc->addScript('js/ckeditor/ckeditor.js'); $doc->addScript('js/app/settings/field.js'); $doc->addInitObject('App_Settings_New', [[ 'id' => 'value', 'mode' => 'edit', 'config' => [ 'toolbar' => 'Default', 'height' => 250, 'contentsCss' => '/Quick_Site_Framework/trunk/www/css/ckeditor.css', ], ]]); return parent::render($view); } }