Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend_Form: Using HtmlTag Decorator twice?

Is it possible to wrap the form element in a div AND the whole block (label, element, errors etc) in another div using the HtmlTag decorator? I'd like to use Twitter's Bootstrap with Zend_Form like so:

<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?

like image 302
ottsch Avatar asked Aug 28 '11 15:08

ottsch


2 Answers

Try this (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: Label was wrong; adjusted.

like image 101
Decent Dabbler Avatar answered Oct 12 '22 12:10

Decent Dabbler


In reply to Ezequiel Muns, here's where it is in the documentation: http://framework.zend.com/manual/1.7/en/zend.form.elements.html#zend.form.elements.decorators Look for the callout section "Note: Using Multiple Decorators of the Same Type."

like image 43
yearofthetiger Avatar answered Oct 12 '22 10:10

yearofthetiger