开发者

Zend_Form - loadDefaultDecorators :: How to remove decorators label + HtmlTag with loadDefaultDecorators function?

How to remove decorators label + HtmlTag with loadDefaultDecorators function?

My solution - please tell me if my implementation working well or need modifications

class MyForm extend Zend_Form{

    function init(){
     //create form elements
     ......................................
    }

public function loadDefaultDecorators() {
  if ($this->loadDefaultDecor开发者_StackOverflowatorsIsDisabled ()) {
   return $this;
  }
  foreach($this->getElements()as $elem){
   $elem->removeDecorator('Label')
        ->removeDecorator('HtmlTag');
        }
  return $this;
  }
}

Thanks


You had overriden loadDefaultDecorators method for MyForm class, but you had to do that for every element class. In this case you will not see any form HTML code, because you didn't provide form specific decorators, like Form, FormElements, etc. All these decorators I described above are defined in the loadDefaultDecorators method of the Zend_Form class. Try to add the following line at the start of your loadDefaultDecorators method:

parent::loadDefaultDecorators();

This will call correspond method of the Zend_Form class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜