开发者

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

开发者 https://www.devze.com 2023-01-08 00:26 出处:网络
How to remove decorators label + HtmlTag with loadDefaultDecorators function? My solution - please tell me if my implementationworking well or need modifications

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

精彩评论

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

关注公众号