/ Published in: PHP
2 main objectives:
- change default decorators of element and form
- `setValues()` mainly used for persisting form entry from request params across requests
- change default decorators of element and form
- `setValues()` mainly used for persisting form entry from request params across requests
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Application_Form_Abstract extends Zend_Form { function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } // for elements $decorators = $this->_elementDecorators; 'ViewHelper', 'Errors', 'Label', )); $this->getElement('submit')->removeDecorator('Label'); } // for form $decorators = $this->getDecorators(); $this->addDecorator('FormElements') ->addDecorator('Form'); } return $this; } function setValue($element, $value) { $this->getElement($element)->setValue($value); } function setValues($values) { foreach ($this->getElements() as $elem) { $elem->setValue($values[$elem->getName()]); } } } }