我有一个带有单选按钮的表单:
$this->add([
'name' => 'time',
'options' => [
'value_options' => [
'0' => '9:00 - 12:00',
'1' => '12:00 - 16:00',
'2' => '16:00 - 19:00',
],
'label_attributes' => [
'class' => 'WW_OBJ_fm-label',
]
],
'type' => 'Radio'
]);
在视图中,我的输出如下:
<div>
<?php echo $this->formElement($form->get('time')); ?>
</div>
并获取输出(为便于阅读而格式化):
<div>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="0"/>
9:00 - 12:00
</label>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="1"/>
12:00 - 16:00
</label>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="2"/>
16:00 - 19:00
</label>
</div>
但我需要,该标签文本由 a 包裹<span>
:
<div>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="0"/>
<span class="WW_label-text">9:00 - 12:00</span>
</label>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="1"/>
<span class="WW_label-text">12:00 - 16:00</span>
</label>
<label class="WW_OBJ_fm-label">
<input type="radio" name="time" value="2"/>
<span class="WW_label-text">16:00 - 19:00</span>
</label>
</div>
实现它的最佳方法是什么?