开发者

Zend Form Radio Button format problem

开发者 https://www.devze.com 2023-02-07 17:26 出处:网络
I have a problem with the radio element in Zend_Form. I have a decorator for the form, it\'s this:\" $this->setElementDecorators(array(

I have a problem with the radio element in Zend_Form.

I have a decorator for the form, it's this:"

$this->setElementDecorators(array(
                   'Label',
          开发者_JAVA技巧         'ViewHelper',
                   'Errors',
                   array('HtmlTag', array('tag' => 'div', 'class' => 'clearfix')),
               ));

It works for all elements in the form except the radiobuttons. After some research I found out that the input element is being placed inside the label tags, and the rest of the form has only the text in the setLabel method.

Is there a way to get it out of there because this is ruining my layout and I can't figure out how to do this the correct way.


Welcome to ZF Decorators, get a helmet. I find them useless, bad, rubbish and pretty uninviting to anyone wanting to start using ZF.

But, get into them! Write your own , override the default one for Radio Buttons and make it work for you. Without this knowledge of ZF Decorators you will always be battling with the layout of forms or resorting to jQuery to reposition elements because the ZF Decorators didn't work as they wanted.

In short, read the docs, write your own and start enjoying them.


you can change it in ZendRadio.php. Go to line 159 and change it to what ever you like.


One solution is to create your own version of Zend_View_Helper_FormRadio. Call it My_View_Helper_FormRadio and add your custom prefix path to the view (this can be done via your config file).

Then you will have complete control over the internal rendering (from the point of the ViewScript decorator).

If you provide an example of how you want the markup to render, I can elaborate or suggest an alternative.

0

精彩评论

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

关注公众号