_listForm = $value; return $this; } protected function _initElements() { $this->addElement('hidden', 'productId'); if ($this->_listForm) { $this->addElement('hidden', 'quantity', ['value' => 1]); } else { $this->addElement( 'numeric', 'quantity', ['label' => 'Quantity:', 'required' => true, 'precision' => 0, 'class' => 'quantity'] ); $quantity = $this->getElement('quantity'); $quantity->addValidator('Int'); $greaterThan = new Zend_Validate_GreaterThan(0); $greaterThan->setMessage( 'Quantity must be greater than zero', Zend_Validate_GreaterThan::NOT_GREATER ); $quantity->addValidator($greaterThan, false); $quantity->getDecorator('Label')->setOption('class', 'quantity_label'); } return $this; } protected function _initButtons() { $this->addElement( 'submit', 'btnSubmit', [ 'label' => 'Add To Cart', 'attribs' => ['class' => 'btn btn-primary'], ] ); return $this; } public function render(Zend_View_Interface $view = null) { $this->getDoc()->addScript('js/app/ECommerce/product/add-to-cart.js'); return parent::render($view); } }