php Zend Framework - 仅在尚未更改装饰器时更改装饰器

时间:2011-09-16 10:45:52

标签: php zend-framework zend-form zend-decorators

我实际上正在寻找一种很好的方法来为我的所有表单元素设置通用装饰器,但同时能够非常具体地更改某些元素的一些装饰器。

说我希望我的所有元素都有新的通用装饰器。我会在我的父通用表单类的addElement方法中执行此操作。例如,在扩展My_Form的{​​{1}}类中,将扩展Zend_Form包含实际元素声明的类,我会有类似的内容:

My_Form_User

现在,我对某些形式的某些元素有非常具体的需求。所以我在创建元素时设置了这些装饰器(在public function addElement($element, $name = null, $options = null) { parent::addElement($element, $name, $options); if (! is_object($element)) { $element = $this -> getElement($name); } if (is_object($element)) { $element -> clearDecorators(); $element -> addDecorators($this -> elementDecorators); } return $this; } 类中)但是,当然,当我将它们添加到带有My_Form_User的表单时,我找不到一种方法来检查是否1装饰器(addElementViewHelperDescription ...)已被修改,以便我不会删除它。

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

它有点短,但是......

  • getDecorator($名)
  • getDecorators()
  • removeDecorator($名)

......也许这有帮助。

相关问题