/** * @Route("/question/{id}/modifier", name="question_edit") */ public function editAction(Request $request, Question $question) { $category = $question->getCategory(); $form = $this->createForm(new QuestionType(), $question); $form->handleRequest($request); if ($form->isValid() && $form->isSubmitted()) { $em = $this->getDoctrine()->getEntityManager(); $em->flush(); return $this->redirect($this->generateUrl('category_show', ['id' => $category->getId()])); } return $this->render(':question:edit.html.twig', ['form' => $form->createView()]); }