根据Zend_Form_Element_Radio中的require HTML装饰无线电元素

时间:2013-05-16 13:12:08

标签: zend-framework zend-form zend-form-element

我写了以下setDecorators无线电元素,

$objUserGender = new Zend_Form_Element_Radio('userGender');
$objUserGender
      ->addFilter('StripTags')
      ->addFilter('StringTrim')
      ->setDecorators(array('ViewHelper'))
      ->addMultiOptions(array(
           'Practice' => 'Practice',
           'Qualifying' => 'Qualifying'))
      ->setValue('Male')
      ->removeDecorator('DtDdWrapper')         
      ->setDecorators(array("ViewHelper",array('label', array('class'=>'label_radio'))))
      ->setSeparator(' ');

这会产生以下结果,

<label for="userGender-Practice">
    <input type="radio" checked="checked" value="Practice" id="userGender-Practice" name="userGender">Practice
</label>
<label for="userGender-Qualifying"><input type="radio" value="Qualifying" id="userGender-Qualifying" name="userGender">Qualifying
</label>

但我想在label标签中添加class并想要输出

                <label class="label_radio" for="radio-01">
                      <input name="sample-radio" id="radio-01" value="1" type="radio"> 
                      Male
                </label>
                <label class="label_radio" for="radio-02">
                      <input name="sample-radio" id="radio-02" value="2" type="radio"> 
                      Female
                </label>

请帮助将类设置为Label

谢谢,

0 个答案:

没有答案