public function listcommentAction(Request $request) { if ('POST' === $request->getMethod()) { $nom = $request->request->get('auteur'); $msg = $request->request->get('message'); $id = $request->request->get('idblog'); $em = $this->getDoctrine()->getEntityManager(); $blog = $em->getRepository('HamdiBlogBundle:Blog')->find($id); $comment = new Comment(); $comment->setUser($nom); $comment->setComment($msg); $comment->setBlog($blog); $em->persist($comment); $em->flush(); } return $this->redirect($this->generateUrl('HamdiBlogBundle_blog_show', array('id' => $id))); }