Reputation: 25827
How to remove decorators label + HtmlTag with loadDefaultDecorators function?
My solution - please tell me if my implementation working well or need modifications
class MyForm extend Zend_Form{
function init(){
//create form elements
......................................
}
public function loadDefaultDecorators() {
if ($this->loadDefaultDecoratorsIsDisabled ()) {
return $this;
}
foreach($this->getElements()as $elem){
$elem->removeDecorator('Label')
->removeDecorator('HtmlTag');
}
return $this;
}
}
Thanks
Upvotes: 0
Views: 769
Reputation: 1097
You had overriden loadDefaultDecorators method for MyForm class, but you had to do that for every element class. In this case you will not see any form HTML code, because you didn't provide form specific decorators, like Form, FormElements, etc. All these decorators I described above are defined in the loadDefaultDecorators method of the Zend_Form class. Try to add the following line at the start of your loadDefaultDecorators method:
parent::loadDefaultDecorators();
This will call correspond method of the Zend_Form class.
Upvotes: 2