ajouter un commentaire

Par houssem, il y a 11 ans


salut je reviens avec mes probleme dans symfony

j'ai essai d'ajouter un commentaire en utilisant les paramconverter

mais j'ai rencontre cette erreur
Unable to guess how to get a Doctrine instance from the request information.

/** * @ParamConverter("news", class="SNSysNewsBundle:News", options={"repository_method" = "findById"}) */ public function addcommentAction(News $news, Request $req) { $com = new Comment(); $form = $this->createForm(new CommentType(), $com); if ($form->handleRequest($req)->isValid()) { $com->setNews($news); $com->setUser($this->getUser()); $news->addComment($com); $em->persist($com); $em->flush(); $req->getSession()->getFlashBag()->add('notice', 'commentaire bien enregistrée.'); return $this->redirect($this->generateUrl('sn_sys_news_view', array( 'id' => $news->getId())));} return $this->render('SNSysNewsBundle:News:addcomment.html.twig', array( 'form' => $form->createView() ));}

2 réponses

iiNku, il y a 11 ans

On peut voir la définition de ta route ?

houssem, il y a 11 ans

salut j'ai resolut cette probleme mais j'ai tombe sur un autre erreur