I have a form with PUT method
{{ form(formEdit, {'action': path('user_update',{'id':user.id}), 'method': 'PUT'}) }}
And My Action is
/**
* Edits an existing User entity.
*
* @Route("/{id}", name="user_update")
* @Method("PUT")
* @Template("foo:User:update.html.twig")
* @ParamConverter("User", class="foo:User")
*/
public function updateAction(Request $request,User $user){
$form = $this->createForm(new UserType(), $user);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
return $this->redirect($this->generateUrl('user',array('id' => $user->getId())));
}
return array(
'formEdit' => $form->createView(),
'user' => $user
);
}
My Twig
{{ form(formEdit, {'action': path('user_update',{'id':user.id}),'method':'PUT'}) }}
When I Submitted the form, I haven't any errors. If I Change PUT with POST, the form works. I tried with
echo $request->getMethod();
echo $form->getErrorsAsString();
and this is my output
PUT
name: No errors surname: No errors email: No errors gender: 0: No errors 1: No errors submit: No errors name: No errors surname: No errors email: No errors gender: 0: No errors 1: No errors submit: No errors
But I don't understand how can i Catch that error. I'm using Symfony 2.3