相关疑难解决方法(0)

Zend框架-Zend_Form装饰器问题

我有一个扩展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);
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,我使用该类创建所有表单:

class ExampleForm extends Core_Form
{
    public function init()
    {
        // Example Field
        $example = new Zend_Form_Element_Hidden('example');
        $this->addElement($example);
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的一种观点中,我需要显示这一字段(Zend_Form不会生成任何其他内容)。所以我认为我有:

<?php echo $this->exampleForm->example; ?>
Run Code Online (Sandbox Code Playgroud)

这工作正常,除了它会生成如下所示的字段:

<li><input type="hidden" name="example" value=""></li>
Run Code Online (Sandbox Code Playgroud)

这显然是因为我将元素装饰器设置为包括HtmlTag:tag =>'li'。

我的问题是:如何禁用此元素的所有装饰器。隐藏的输入元素不需要装饰器。

php zend-framework zend-form

4
推荐指数
1
解决办法
6053
查看次数

标签 统计

php ×1

zend-form ×1

zend-framework ×1