gpt4 book ai didi

forms - 如何为选择标签元素设置类?

转载 作者:行者123 更新时间:2023-12-02 05:17:00 25 4
gpt4 key购买 nike

如何为选择元素添加标签类?如果不在 Twig 模板中这样做,这是否可能?

呈现的表单选择元素:

<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
]
])
//...

最佳答案

 ->add("currency", "choice",[
'choices'=>[
'1' => 'one',
'2' => 'two'
],
'expanded' => true,
'label_attr' =>[
'class' => 'cssClassName'
]
])

干杯!

关于forms - 如何为选择标签元素设置类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35191999/

25 4 0