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