Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 3.4表单中的字段循环_Php_Symfony_Twig_Symfony Forms - Fatal编程技术网

Php Symfony 3.4表单中的字段循环

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

我有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>
{% 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,
        ])
    ;
}