addElement( 'text', 'query', ['label' => 'Search', 'size' => 50, 'filters' => [new Zend_Filter_StringTrim()]] ); $this->_setQueryDescription(); return $this; } public function setOptions(array $options) { if (isset($options['filterFields'])) { $this->_filterFields = $options['filterFields']; unset($options['filterFields']); } if (isset($options['filterQueryDescriptionFormat'])) { $this->_filterQueryDescriptionFormat = $options['filterQueryDescriptionFormat']; unset($options['filterQueryDescriptionFormat']); } if (isset($options['descriptionPlaceholder'])) { $this->_descriptionPlaceholder = $options['descriptionPlaceholder']; unset($options['descriptionPlaceholder']); } return parent::setOptions($options); } protected function _setQueryDescription() { if (!empty($this->_filterFields)) { $description = $this->_filterQueryDescriptionFormat; if (false !== strpos($description, $this->_descriptionPlaceholder)) { $fields = '"' . Qs_Array::implodeLast('", "', '" or "', $this->_filterFields) . '"'; $description = str_replace($this->_descriptionPlaceholder, $fields, $this->_filterQueryDescriptionFormat); } $this->getElement('query')->setDescription($description); } return $this; } protected function _initButtons() { if (!$this->_hasButtons) { return $this; } $this->addElement( 'submit', 'btnSearch', [ 'label' => 'Search', 'ignore' => true, 'attribs' => ['class' => 'btn btn-primary'], ] ); $this->addElement( 'submit', 'btnCancel', [ 'label' => 'Reset', 'ignore' => true, 'attribs' => [ 'class' => 'btn', 'onclick' => "document.location='" . constant('BASE_URL') . '/' . constant('CURRENT_PAGE') . "';", 'helper' => 'formInputButton', ], ] ); $this->addDisplayGroup(['btnSearch', 'btnCancel'], 'submitGroup'); return $this; } public function isSubmitted() { $method = $this->getMethod(); if (0 == strcasecmp($_SERVER['REQUEST_METHOD'], $method)) { $formData = ($method == 'get') ? $_GET : $_POST; if (array_key_exists('__idItem', $this->_elements)) { if ($this->getElement('__idItem')->getValue() == Qs_Array::get($formData, '__idItem')) { return true; } } else { /** @var Zend_Form_Element $element */ foreach ($this->_elements as $element) { if (array_key_exists($element->getName(), $formData)) { return true; } } } } return false; } }