getConfig(); $this->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $this->_initMetaTitleElement( [ 'description' => 'This information will show in the browser tab and in search results. ' . 'If you leave this field empty - the Page Title will be the same as Title.' ] ); $this->addElement('pageAlias', 'alias', array( 'label' => 'Alias', 'required' => true, 'maxlength' => 200, 'sourceField' => 'title', 'aliasValidatorOptions' => array( 'table' => new Qs_Db_Table('Product'), 'column' => 'alias', 'currentId' => $this->_getData('id') ) ) ); $this->_initMetaKeywordsElement(); $this->_initMetaDescriptionElement(); $this->addElement( 'categoriesSelector', 'categories', array( 'label' => 'Category', 'required' => true, 'multiOptions' => $categoriesObj->getCategoryTree(), 'treeViewOptions' => array( 'collapsed' => true, 'persist' => 'location', 'animated' => 'medium' ) ) ); $this->_addOptionsElement(); $this->addElement('numeric', 'price', array('label' => 'Price ($)', 'negative' => false, 'required' => true)); $this->addElement('numeric', 'weight', array('label' => 'Weight (lbs)', 'negative' => false, 'required' => true)); $this->getElement('weight')->addValidator('GreaterThan', false, array(0)); $this->getElement('weight')->getValidator('GreaterThan')->setMessage( 'Weight must be greater than zero', Zend_Validate_GreaterThan::NOT_GREATER ); $this->addElement( 'extendedImage', 'image', array( 'label' => 'Image', 'resize' => $config->image->width . 'x' . $config->image->height . $config->image->resizeMethodAlias, ) ); $this->addElement('htmlEditor', 'description', array('label' => 'Description', 'toolbar' => 'Basic')); return $this; } protected function _addOptionsElement() { $this->addElement('checkbox', 'enabled', array('label' => 'Show on user end', 'decoration' => 'simple')); $this->addElement('checkbox', 'featured', array('label' => "Mark as 'Featured'", 'decoration' => 'simple')); $this->addElement('checkbox', 'soldOut', array('label' => "Mark as 'Sold Out'", 'decoration' => 'simple')); $this->addElement( 'checkbox', 'applyTax', array('label' => 'Apply tax', 'decoration' => 'simple') ); $this->addDisplayGroup(array('enabled', 'featured', 'soldOut', 'applyTax'), 'productOptions'); /** @var Qs_Form_Decorator_DtDdWrapper $dtDdWrapper */ $dtDdWrapper = $this->getDisplayGroup('productOptions')->getDecorator('DtDdWrapper'); $dtDdWrapper->setOption('label', 'Product Options'); return $this; } protected function _initButtons() { if (!$this->_hasButtons) { return $this; } $this->addElement('hidden', 'postAction', array('value' => '')); $this->addElement( 'submit', 'btnSubmit', array( 'label' => 'Save', 'attribs' => array('class' => 'btn btn-primary'), 'onclick' => '$("#postAction").val("' . self::POST_ACTION_SAVE . '")', ) ); $this->addElement( 'submit', 'btnEditImages', array( 'label' => 'Save & Edit Images', 'attribs' => array('class' => 'btn btn-primary'), 'onclick' => '$("#postAction").val("' . self::POST_ACTION_EDIT_IMAGES . '")', ) ); $this->addElement( 'submit', 'btnCancel', array( 'label' => 'Cancel', 'attribs' => array( 'class' => 'btn', 'onclick' => "window.location.href = '" . htmlspecialchars($this->getCancelUrl()) . "';", 'helper' => 'formInputButton', ), ) ); $this->addDisplayGroup(array('btnSubmit', 'btnEditImages', 'btnCancel'), 'submitGroup'); return $this; } }