开发者

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 ide开发者_Go百科as?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜