public function putTodosAction(Request $request, $id)
{
$todo = $this->getDoctrine()->getRepository('AcmeDemoBundle:Todo')->find($id);
if (!$todo) {
throw $this->createNotFoundException("Todo does not exist.");
}
$form = $this->createForm(new TodoType(), $todo);
$form->submit($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($todo);
$em->flush();
$view = $this->routeRedirectView('get_todo', ['id' => $todo->getId()])->setTemplate('AcmeDemoBundle:Todo:getTodo.html.twig')->setTemplateVar('todo')->setData($todo);
} else {
$view = $this->view(['form' => $form], 400);
}
return $this->handleView($view);
}