我有一個擴展Zend_Form的這樣一類(簡體):Zend框架 - 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:標籤= >'李'。
我的問題是:如何禁用此元素的所有裝飾器。我不需要裝飾器來隱藏輸入元素。
謝謝!我不知道爲什麼我沒有考慮重寫loadDefaultDecorators()函數。 – leek 2008-12-18 13:17:52