Php Symfony 3.4表单中的字段循环
我有6个带有标签和名称的复选框的简单表单 我只想将它们显示到引导模板中:Php Symfony 3.4表单中的字段循环,php,symfony,twig,symfony-forms,Php,Symfony,Twig,Symfony Forms,我有6个带有标签和名称的复选框的简单表单 我只想将它们显示到引导模板中: {% for child in form.children %} <div class="col-md-4 text-right"> {{ form_label(child) }} </div> <div class="col-md-8"> {{ form_widget(child) }} </div> {% e
{% for child in form.children %}
<div class="col-md-4 text-right">
{{ form_label(child) }}
</div>
<div class="col-md-8">
{{ form_widget(child) }}
</div>
{% endfor %}
我看错文件了吗?看起来你在使用引导,这可能是预期的行为,请看是的,它完全符合此行为,非常感谢,将改变它。就像你在使用引导一样,这可能是预期的行为,请看是的,它完全符合此行为,非常感谢,将改变它
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name1', CheckboxType::class, [
'label' => 'Label 1',
'attr' => [
'class' => 'switchery'
],
'required' => false,
])
->add('name2', CheckboxType::class, [
'label' => 'Label 2',
'attr' => [
'class' => 'switchery'
],
'required' => false,
])
->add('name3', CheckboxType::class, [
'label' => 'Label 3',
'attr' => [
'class' => 'switchery'
],
'required' => false,
])
->add('name4', CheckboxType::class, [
'label' => 'Label 4',
'attr' => [
'class' => 'switchery'
],
'required' => false,
])
;
}