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'
));