如何为选择元素添加标签类?如果不在树枝模板中进行,这甚至是可能的吗?
呈现表单选择元素:
<div>
<label class="required">Type</label>
<div id="AddNewAdType_type">
<input type="radio" id="AddNewAdType_type_0" name="AddNewAdType[type]" required="required" value="b">
<label for="AddNewAdType_type_0" class="required">one</label> // add css class here
<input type="radio" id="AddNewAdType_type_1" name="AddNewAdType[type]" required="required" value="s">
<label for="AddNewAdType_type_1" class="required">two</label> // add css class here
</div>
</div>
例如:
//...
->add("currency", "choice",[
'choices'=>[
'1' => 'one',
'2' => 'two'
],
'expanded' => true,
'choice_attr' =>[
'class' => 'cssClassName' //won't work
]
])
//...
答案 0 :(得分:-1)
->add("currency", "choice",[
'choices'=>[
'1' => 'one',
'2' => 'two'
],
'expanded' => true,
'label_attr' =>[
'class' => 'cssClassName'
]
])
喝彩!