Disable default decorator(s) for Zend_Form_Element
On 08/05/2012 Zend FrameworkIn this article i will describe some methods to remove/disable default decorators from Zend_Form_Element. Basicly are two method, one by calling some method if we had an instance of object Zend_Form_Element, and other if we extend or we build a custom Zend_Form_Element is from init method.
So maybe sometimes we don't want that every html input to be encapsulated in dl/dt/dd structure. To achive this we can use:
$element = new Zend_Form_Element_Text('name', array('disableLoadDefaultDecorators' = true));
or from inside of class wich inherits Zend_Form_Element class:
class Form_Element_Custom extends Zend_Form_Element { public function init() { $this->_disableLoadDefaultDecorators=true; } }
After disabling all default decorators is posible that our Zend_Form_Element to not be rendered at all in html form. In this case we add back a simple decorator that will render html input without d;/dt/dd structure, like this:
$element->addDecorator('ViewHelper');