Symfony2 : Two forms in a same page

前端 未结 7 797
感情败类
感情败类 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

    This is how I handle them on my controller :

    return $this->render('SgaDemandeBundle:Demande:suivi_avancement.html.twig', 
                         array('form' => $form->createView(), 
                               ........
                               'update' => $formModification->createView()));
    

    This is the html for the second form :

    This is my twig rendered :

    {{ form_widget(update) }}
    {{ form_widget(form) }}
    {{ form_errors(form) }}

    I hope this will help you.

提交回复
热议问题