ottsch
ottsch

Reputation: 431

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?

Upvotes: 5

Views: 2528

Answers (2)

yearofthetiger
yearofthetiger

Reputation: 56

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."

Upvotes: 2

Decent Dabbler
Decent Dabbler

Reputation: 22783

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.

Upvotes: 8

Related Questions