开发者

Zend_Form_Element label in row and element in row

how to decorate zend form element to put label in tr and element in tr

<tr><td><label>name</label></td></开发者_Python百科tr>
<tr><td><input type="text"/></td></tr>

i use this code

$this->setElementDecorators(
    array('ViewHelper',
    array(array('data'=>'HtmlTag'),array('tag'=>'td','class'=>'element_td')),
    array('Label',array('tag'=>"td")),
    array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
    )
);

but it produce label and elemment in same row[tr] i want label in row and the element in another row how to do this??


It's a bit tricky to do this with the decorators, but it's possible. Since you want to wrap two individual components within tags that are separate from each other, what you must do is first wrap one of them using the HtmlTag decorator, and after that build the other one by appending decorators after it (or optionally the other way around and prepending):

$this->setElementDecorators(array(
    array('Label'),
    array(array('labelTd'=>'HtmlTag'),array('tag'=>'td','class'=>'label_td')),
    array(array('labelTr'=>'HtmlTag'),array('tag'=>'tr','class'=>'label_tr')),
    array(array('elementOpenTr'=>'HtmlTag'),array('tag'=>'tr','class'=>'element_tr','openOnly'=>true,'placement'=>'append')),
    array(array('elementOpenTd'=>'HtmlTag'),array('tag'=>'td','class'=>'element_td','openOnly'=>true,'placement'=>'append')),
    array('ViewHelper', array('placement' => 'append')),
    array(array('elementCloseTd'=>'HtmlTag'),array('tag'=>'td','closeOnly'=>true,'placement'=>'append')),
    array(array('elementCloseTr'=>'HtmlTag'),array('tag'=>'tr','closeOnly'=>true,'placement'=>'append'))
));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜