Zend无线电元素装饰

时间:2012-08-23 04:05:29

标签: zend-framework

  

可能重复:
  Display Zend_Form_Element_Radio on one line

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

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

如何删除“&lt; br&gt;”每个&lt;之后标记标签&gt;?

2 个答案:

答案 0 :(得分: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('  ');

答案 1 :(得分:2)

<br />是Zend_Form_Element_Radio的默认分隔符,然后试试:

$radio->setSeparator('');