Symfony2 : Two forms in a same page

前端 未结 7 807
感情败类
感情败类 2020-12-05 23:50

I\'ve got two forms in a same page.

My problem is when I tried to submit a form, it\'s like it tried to submit the second form below in the page as well.

As

7条回答
  •  难免孤独
    2020-12-06 00:49

    The two forms will be posted.

    Try using:

        $this->createNamedBuilder 
    

    instead of

        $this->createFormBuilder
    

    Then in your controller, locate the form by name:

    if ($request->request->has("your form name") {
       $form->handleRequest($request);
    }
    

提交回复
热议问题