Revision: 29309
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 26, 2010 19:23 by jiewmeng
Initial Code
class Application_Form_Abstract extends Zend_Form {
function loadDefaultDecorators() {
if ($this->loadDefaultDecoratorsIsDisabled()) {
return $this;
}
// for elements
$decorators = $this->_elementDecorators;
if (empty($decorators)) {
$this->setElementDecorators(array(
'ViewHelper',
'Errors',
array('Description', array('tag' => 'p')),
'Label',
array('HtmlTag', array('tag' => 'p'))
));
$this->getElement('submit')->removeDecorator('Label');
}
// for form
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('FormElements')
->addDecorator('Description', array('placement' => 'PREPEND', 'tag' => 'p'))
->addDecorator('Form');
}
return $this;
}
function setValue($element, $value) {
$this->getElement($element)->setValue($value);
}
function setValues($values) {
foreach ($this->getElements() as $elem) {
if (!$elem->getIgnore() && array_key_exists($elem->getName(), $values)) {
$elem->setValue($values[$elem->getName()]);
}
}
}
}
Initial URL
Initial Description
2 main objectives: - change default decorators of element and form - `setValues()` mainly used for persisting form entry from request params across requests
Initial Title
Custom Zend_Form: Changed Decorators & added methods
Initial Tags
Initial Language
PHP