Forms Zend表单装饰问题
*我英语说得不好。所以我现在要发布代码。* 表格编号:Forms Zend表单装饰问题,forms,zend-framework,zend-decorators,Forms,Zend Framework,Zend Decorators,*我英语说得不好。所以我现在要发布代码。* 表格编号: protected $elementDecorators = array('ViewHelper','Errors','Description','Label', array('HtmlTag',array('tag' => 'div','class' => '_wrapperElement') )); public function init(){
protected $elementDecorators = array('ViewHelper','Errors','Description','Label',
array('HtmlTag',array('tag' => 'div','class' => '_wrapperElement')
));
public function init(){
$this->addElement('text','mytext',array(
'class' => '_inputText',
'label' => 'Mytext',
'required' => true,
'decorators' => $this->elementDecorators
));
$this->setDecorators(array('FormElements',array('HtmlTag',array('tag' => 'div','class' => '_formWrapper')),'Form'));
}
输出:
<form method="post" action="" enctype="application/x-www-form-urlencoded">
<div class="_formWrapper">
<div class="_wrapperElement">
<label class="required" for="mytext">Mytext</label>
<input type="text" class="_inputText" value="" id="mytext" name="mytext">
</div>
</div>
</form>
我的文本
现在我想要一个div包装标签和输入元素,如下所示:
<form method="post" action="" enctype="application/x-www-form-urlencoded">
<div class="_formWrapper">
<div class="_wrapperElement">
<div class="_wrapperLabel">
<label class="required" for="mytext">Mytext</label>
</div>
<div class="_wrapperInput">
<input type="text" class="_inputText" value="" id="mytext" name="mytext">
</div>
</div>
</div>
</form>
我的文本
怎么做
我试了很多次,但都做不到
谢谢 我找到了向ViewScript呈现装饰器的解决方案
protected $elementDecorators = array('ViewHelper','Errors','Description', array('Label', array('tag' => 'div', 'class' => '_wrapperLabel')
),
array('HtmlTag',array('tag' => 'div','class' => '_wrapperInput')
));