【发布时间】:2008-12-17 22:00:02
【问题描述】:
我有一个像这样(简化)扩展 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);
}
}
在我的一个观点中,我需要只显示这一个字段(没有其他任何由 Zend_Form 生成的字段)。所以在我看来,我有这个:
<?php echo $this->exampleForm->example; ?>
这很好用,除了它会生成这样的字段:
<li><input type="hidden" name="example" value=""></li>
这显然是因为我将元素装饰器设置为包含 HtmlTag: tag => 'li'。
我的问题是:如何禁用此元素的所有装饰器。我不需要隐藏输入元素的装饰器。
【问题讨论】:
标签: php zend-framework zend-form