简体   繁体   中英

Zend Form Radio Button format problem

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',
                   '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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM