【发布时间】:2017-09-27 18:03:33
【问题描述】:
我正在尝试将一些 css 类添加到 ChoiceType 表单中,在我的情况下是一个单选框(我将选项“multiple”设置为 false,将选项“expanded”设置为 true)。
我不知道应该使用哪个选项,我尝试了 attr 和choice_attr,但没有成功。
我的问题是:
如何给收音机和收音机的文字添加css类?
$builder
->add('enLigne', ChoiceType::class, [
'choices' => $publier,
'attr' => [
'class' => 'radio',
],
'choice_attr' => function($val, $key, $index) {
return ['class' => 'ace input-lg'];
},
'multiple' => false,
'expanded' => true,
'label' => 'Publier *',
'label_attr' => [
"class" => "smaller lighter blue",
"style" => "font-size: 21px;",
]
])
我想做一个这样的单选框:
HTML 代码:
<div class="radio">
<label>
<input name="form-field-radio" type="radio" class="ace input-lg">
<span class="lbl bigger-120"> large radio</span>
</label></div>
【问题讨论】:
-
使用
add第三个参数写这个array('attr'=>array('class', 'attr_name')) -
对不起,如何使用添加第三个参数?
-
对不起,看错了你的代码...你已经使用了我上面说的...如果您需要在表单中自定义另一个特定元素,那么直接使用css...
your_class input[type=radio] -
对不起,我不太明白你能不能把代码。
-
您好,我需要帮助。
标签: css symfony symfony-forms