2

可能重复:
在一行上显示 Zend_Form_Element_Radio

我使用以下代码生成单选按钮:

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

这会产生以下 HTML 输出:

<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>

如何删除每个<标签>之后的“<br>”标签?

4

2 回答 2

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('  ');
于 2012-08-24T03:07:50.277 回答
2

<br />是 Zend_Form_Element_Radio 的默认分隔符,那么让我们试试:

$radio->setSeparator('');
于 2012-08-23T07:06:40.727 回答