【发布时间】:2011-01-31 13:35:02
【问题描述】:
是否可以在 zend 表单上创建没有字段集的子表单和显示组?
【问题讨论】:
标签: zend-framework zend-form zend-form-sub-form
是否可以在 zend 表单上创建没有字段集的子表单和显示组?
【问题讨论】:
标签: zend-framework zend-form zend-form-sub-form
是的,这是可能的。
您可以像这样在您的特定表单中覆盖 loadDefaultDecorators Zend_Form 原始方法:
public function loadDefaultDecorators() {
parent::loadDefaultDecorators();
// remove the 'fieldset' decorator from all subforms
$subforms = $this->getSubForms();
foreach($subforms as $subform) {
$subform->removeDecorator('Fieldset');
}
return $this;
}
当您基于例如从选择列表中选择的选项动态加载子表单时,这可能会有所帮助。 希望这会对某人有所帮助。
【讨论】:
为什么要这样做?
这是有用的辅助功能吗?
但是,您可以通过多种方式执行此操作,例如继承 Zend_Form 并设置自己的装饰器,或使用 getDecorators()、addDecorator() setDecorators() 或 removeDecorator() 方法。
【讨论】: