Bonjour,
Débutant avec Symfony2, je me rapproche de vous pour une information.
En effet, j'ai un contrôleur disposant de la méthode render() pour l'affichage du template twig.
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public function afficherTousAction() { $em = $this->getDoctrine()->getManager(); $producteur = $em->getRepository('VignobleProducteurBundle:Producteur') ->afficherTous(); $em->flush(); return $this->render('VignobleProducteurBundle:Vignoble:index.html.twig', array("producteur" => $producteur)); }
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 class ProducteurRepository extends EntityRepository { public function afficherTous() { return $this->getEntityManager() ->createQuery('SELECT p FROM VignobleProducteurBundle:Producteur p ORDER BY p.pseudo ASC')->getResult(); } }
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <!DOCTYPE html> <head></head> <body> {% for producteur in producteurs %} <li>{{ producteur }}</li> {% endfor %} </body>
J'ai le message d'erreurComment résoudre ce problème car je ne voit pas comment procéder?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Variable "producteurs" does not exist in VignobleProducteurBundle:Vignoble:index.html.twig at line 4
Merci d'avance.
Transact.
Partager