2

Possible Duplicate:
Display Zend_Form_Element_Radio on one line

I hv the following code to generate Radio buttons:

        $radio = new Zend_Form_Element_Radio('rating');
        $radio->setLabel('Rating')
              ->addMultiOptions(array(
            '1' => '1',
            '2' => '2',
            '3' => '3',
            '4' => '4',
            '5' => '5'
        ));

which produce the following HTML output :

<label for="rating-1">
<input id="rating-1" type="radio" value="1" name="rating">
1
</label>
<br>
<label for="rating-2">
<input id="rating-2" type="radio" value="2" name="rating">
2
</label>
<br>
<label for="rating-3">
<input id="rating-3" type="radio" value="3" name="rating">
3
</label>
<br>
<label for="rating-4">
<input id="rating-4" type="radio" value="4" name="rating">
4
</label>
<br>
<label for="rating-5">
<input id="rating-5" type="radio" value="5" name="rating">
5
</label>

How do I remove the "< br >" tag after each < label >?

Community
  • 1
  • 1
redcoder
  • 2,233
  • 4
  • 22
  • 24
  • but one more thing.. is it neccessary to have the < label for="rating-x" > above each input tag? where x is 1,2,3,4,5 – redcoder Aug 23 '12 at 04:51
  • 1
    the `` tags are actually *inside* the labels, and I'd say, "yes, you should keep the labels". – wbit Aug 23 '12 at 05:13

2 Answers2

5
    $radio = new Zend_Form_Element_Radio('rating');
    $radio->setLabel('Rating')
          ->addMultiOptions(array(
        '1' => '1',
        '2' => '2',
        '3' => '3',
        '4' => '4',
        '5' => '5'
    ))
    $radio->setSeparator('  ');
Daya
  • 1,170
  • 10
  • 22
2

<br /> is default separator for Zend_Form_Element_Radio, then let`s try:

$radio->setSeparator('');
Michael
  • 1,067
  • 8
  • 13