If you are building your form in a separate class and not in your controller, you should pass the action
to the form type like this:
// In your controller
$form = $this->createForm(new FormType(), $object, array(
'action' => $this->generateUrl('target_route'),
'method' => 'POST',
));
The AbstractType
does not contain any method generateUrl()
, that's why you can't set the action in the type directly. You can find details here: http://symfony.com/doc/current/book/forms.html#changing-the-action-and-method-of-a-form