我有一个像这样扩展 Zend_Form 的类(简化):
class Core_Form extends Zend_Form
{
protected static $_elementDecorators = array(
'ViewHelper',
'Errors',
array('Label'),
array('HtmlTag', array('tag' => 'li')),
);
public function loadDefaultDecorators()
{
$this->setElementDecorators(self::$_elementDecorators);
}
}
然后我使用该类来创建我的所有表单:
class ExampleForm extends Core_Form
{
public function init()
{
// Example Field
$example = new Zend_Form_Element_Hidden('example');
$this->addElement($example);
}
}
在我的一种观点中,我需要展示only这一字段(没有 Zend_Form 生成的任何其他内容)。所以在我看来我有这样的:
<?php echo $this->exampleForm->example; ?>
这工作得很好,除了它生成这样的字段:
<li><input type="hidden" name="example" value=""></li>
这显然是因为我将元素装饰器设置为包含 HtmlTag: tag => 'li'。
我的问题是:如何禁用该元素的所有装饰器。我不需要隐藏输入元素的装饰器。