Zend_Form: using HtmlTag Decorator twice?

Is it possible to wrap a form element in a div And the entire block (label, element, errors, etc.) in another div using the HtmlTag decorator? I would like to use Twitter Bootstrap with Zend_Form as follows:

<div class="clearfix"> <label for="xlInput">X-Large Input</label> <div class="input"> <input class="xlarge" id="xlInput" name="xlInput" size="30" type="text" /> </div> </div> 

Any ideas?

+4
source share
2 answers

Try this one (untested):

 $element->setDecorators( array( 'Errors', 'ViewHelper', array( array( 'wrapperField' => 'HtmlTag' ), array( 'tag' => 'div', 'class' => 'input' ) ), array( 'Label', array( 'placement' => 'prepend' ) ), array( array( 'wrapperAll' => 'HtmlTag' ), array( 'tag' => 'div', 'class' => 'clearfix' ) ), ) ); 

edit: The label was wrong; adjusted.

+7
source

In response to Ezequiel Muns, where he is in the documentation: http://framework.zend.com/manual/1.7/en/zend.form.elements.html#zend.form.elements.decorators Look for the leader section "Note: use multiple decorators of the same type. "

+2
source

Source: https://habr.com/ru/post/1369382/


All Articles