tags:

views:

149

answers:

1

Hi,

with this piece of code

$feOnline = New Zend_Form_Element_Radio('online');
$feOnline->setValue($article->online)
        ->addMultiOptions(array(0=>'offline', 1=>'online'))
        ->setLabel('Online');

this html is generated

<dd id="online-element">
<label for="online-0">
    <input type="radio" checked="checked" value="0" id="online-0" name="online">offline
</label><br>
<label for="online-1"><input type="radio" value="1" id="online-1" name="online">online
</label>
</dd>

However I don't want the input-tag inside the label-tag. No need for the "
" either...

What decorators must I add to get this output?

<dd id="online-element">
    <input type="radio" checked="checked" value="0" id="online-0" name="online"><label for="online-0">offline</label>
    <input type="radio" value="1" id="online-1" name="online"><label for="online-1">online</label>
</dd>
+1  A: 

If you are using default Zend_View_Helper_FormRadio you can't change the way radio is rendered.
The code is as follows (line 159)

// Wrap the radios in labels
$radio = '<label'
        . $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">'
        . (('prepend' == $labelPlacement) ? $opt_label : '')
        . '<input type="' . $this->_inputType . '"'
        . ' name="' . $name . '"'
        . ' id="' . $optId . '"'
        . ' value="' . $this->view->escape($opt_value) . '"'
        . $checked
        . $disabled
        . $this->_htmlAttribs($attribs)
        . $endTag
        . (('append' == $labelPlacement) ? $opt_label : '')
        . '</label>';

No configuration is in place to change the logic. Think of the reason why you REALLY need to change the way it is rendered, try using CSS to style the output for example.
If you conclude, you need to change rendering, create your own view helper and use it instead of the default one.

michal kralik