如何在ZF中呈现Form元素时删除dd和dt html元素?

Ita*_*vka 12 php zend-framework zend-form

我在我的视图中渲染了一个Zend_Form_Element_Select.

$t=new Zend_Form_Element_Select(....);
...
...
echo $t->render();
Run Code Online (Sandbox Code Playgroud)

我得到了正确的下拉和选项,但我也得到了包含的select元素

<dt> </dt>
<dd>[elm]</dd>
Run Code Online (Sandbox Code Playgroud)

如何删除该装饰器?

Mar*_*zus 18

你有更多的可能性:相关手册:

http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.decorators

第二个是删除你不需要的装饰器

$t->removeDecorator('Errors');
$t->removeDecorator('HtmlTag');
$t->removeDecorator('Label');
Run Code Online (Sandbox Code Playgroud)

第三个(可能是最好的一个)是只设置你需要的装饰器.下面的代码将只设置视图助手装饰器,因此不会有标签,没有错误信息和没有html标签

$t->setDecorators(array(
    array('ViewHelper'),
));
Run Code Online (Sandbox Code Playgroud)

关于装饰器的非常好的文章在这里:

http://devzone.zend.com/article/3450