Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
Forms 表格未在symfony中提交_Forms_Symfony_Submit - Fatal编程技术网

Forms 表格未在symfony中提交

Forms 表格未在symfony中提交,forms,symfony,submit,Forms,Symfony,Submit,在我的控制器内,我有: public function indexAction(Request $request) { $participantEntry = new Participants(); $form = $this->createForm(ParticipantsType::class, $participantEntry,[ 'action' => $request->getUri() ]);

在我的控制器内,我有:

public function indexAction(Request $request)
    {
        $participantEntry = new Participants();

    $form = $this->createForm(ParticipantsType::class, $participantEntry,[
        'action' => $request->getUri()
    ]);


    $form->handleRequest($request);

    if($form->isValid())
    {
        $em = $this->getDoctrine()->getManager();
        $em->persist($participantEntry);
        $em->flush();
    }

    return $this->render('SurveyBundle:Page:index.html.twig',
        ['form' => $form->createView()]);
}
使用此buildForm创建表单的:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
    $builder
        ->add('gender', ChoiceType::class, array(
            'choices'  => array(
                'Male'   => 1,
                'Female' => 2,
            ),
            'expanded' => true,
            'multiple' => false
        ))
        ->add('audio1', ChoiceType::class, array(
            'choices'  => array(
                'Happy'   => 1,
                'Surprised' => 2,
                'Sad' => 3,
                'Angry' => 4,
                'Disgust' => 5,
                'Scared' => 6,
            ),
            'expanded' => true,
            'multiple' => false
        ))
        ->add('age', ChoiceType::class, array(
            'choices'  => array(
                'Less than 18'   => 1,
                '18 - 24' => 2,
                '25 - 34' => 3,
                '35 - 44' => 4,
                '45 - 54' => 5,
                '55 and over' => 6,
            ),
            'expanded' => true,
            'multiple' => false
        ))
        ->add('ethnicity', ChoiceType::class, array(
            'choices' => array(
                'White / Caucasian' => 1,
                'Hispanic / Latino' => 2,
                'Asian' => 3,
                'Black / African American' => 4,
                'Other' => 5,
            ),
            'expanded' => true,
            'multiple' => false
        ))
        ->add('submit',SubmitType::class);

}
然后在我的小树枝文件中将问题显示为单选按钮


但是,当我在选中所有内容的情况下单击“提交”时,表单实际上并没有提交。我做错了什么

尝试在twig视图中指定表单操作,例如:{{form_start(form,{'attr':{'id':'myId'},'action':path('my_route')}}}}}如果您愿意,您可以粘贴生成的HTML吗?表单是否未提交(即页面未刷新)或者数据是否被
拒绝如果($form->isValid())
?尝试指定表单操作,例如,在twig视图中:{{form_start(form,{'attr':{'id':'myId'},'action':path('my_route')}}}}如果愿意,可以使用其他方法粘贴生成的HTML吗?表单是否未提交(即页面未刷新)或者数据是否被
如果($form->isValid())
拒绝?