Symfony-复选框类型

Web*_*r K 1 checkbox symfony

我在symfony框架中的checkboxtype有问题。我的创建表单代码是:

$form = $this->createFormBuilder()
            ->add('table_records', CheckboxType::class)
            ->add('save', SubmitType::class, array('label' => 'delete'))
            ->getForm();
Run Code Online (Sandbox Code Playgroud)

我的问题是复选框中的数组,因为对于许多复选框,我都需要复选框名称,例如table_records []。

Tim*_*ius 5

将ChoiceType与和一起使用,并设置expandedtrue

$builder->add('table_records', ChoiceType::class, array(
    'choices' => array(),
    'expanded' => true
))
Run Code Online (Sandbox Code Playgroud)