2
我有一些與裝飾相關的東西與Zend窗體的隨機問題。Zend表格裝飾問題
首先,
// THIS WORKS AND REMOVES THE DECORATORS
$hidden = new Zend_Form_Element_Hidden('hiddenfield');
$hidden->setRequired(TRUE)
->removeDecorator('label')
->removeDecorator('HtmlTag')
->addErrorMessage('Please upload something');
// BUT IT DOESNT WORK HERE - THE DECORATORS ARENT REMOVED
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Proceed to Part 2 of 2')
->removeDecorator('label')
->removeDecorator('HtmlTag')
->setAttrib('class', 'button fleft cta');
其次,形式元素創建這樣的:
$comments = new Zend_Form_Element_Textarea('comments');
$comments->setLabel('Any comments')
->setRequired(FALSE);
,並加入到一個顯示組是這樣的:
// THIS DOESNT WORK
$this->addDisplayGroup(array('comments'),'comments');
$comms = $this->getDisplayGroup('comments');
$comms->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'Fieldset'
));
心不是加入一個字段但使用相同代碼的自定義表單元素添加到其自己的字段集中:
// THIS WORKS!
$this->addDisplayGroup(array('custom'),'custom',array('legend'=>'Legend Here'));
$swfupload = $this->getDisplayGroup('swfupload');
$swfupload->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'Fieldset'
));