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
The problem is that you have two nameless forms (input names like inputname
instead of formname[inputname]
, and thus when you bind the request to your form and it gets validated it detects some extra fields (the other form) and so it is invalid.
The short-term solution is to create a named builder via the form factory, so instead of:
$form = $this->createFormBuilder(null)
you should use:
$form = $this->get("form.factory")->createNamedBuilder("my_form_name")
The long term solution would be to create your own form classes, that way you can keep your form code separate from the controller.