Bonjour,
Je veux faire un affichage de mes entités qui ont le même CodeSd mais je n'arrive pas à récupérer ma valeur que je sélectionne dans ma liste. Voici mon code :
- Controller
- mon fichier voir :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public function homepageAction() //affichage de la listbox { $db = $this->getDoctrine()->getEntityManager()->getConnection(); // Dans un Controller $sql = "SELECT CodeSd FROM Point GROUP BY CodeSd"; $Liste = $db->prepare($sql); $Liste->execute(); return $this->render('SitePointBundle:Default:homepage.html.twig',array('Liste'=>$Liste)); } public function rechercherAction() //affiche les différents points { $db = $this->getDoctrine()->getEntityManager()->getConnection(); // Dans un Controller $sql = "SELECT * FROM Point WHERE CodeSd="//???; $Liste = $db->prepare($sql); $Liste->execute(); foreach($Liste as $Point) { $CodeSd=$Point->getCodeSd(); return $this->redirect($this->generateUrl('site_point_voir',array('CodeSd'=>$Point->getCodeSd()))); } }
- mon fichier homepage ou il y a ma liste :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 {% extends "SitePointBundle::layout.html.twig" %} {% block title %} Voir {% endblock %} {% block tableau %} <TABLE BORDER="30"> <tr> <th>{{ 'CodeSd' }}</th> <th>{{ 'Id' }}</th> <th>{{ 'Template' }}</th> <th>{{ 'Serveur' }}</th> <th>{{ 'Chemin' }}</th> <th>{{ 'Mini' }}</th> <th>{{ 'Maxi' }}</th> <th>{{ 'Increment' }}</th> <th>{{ 'titre' }}</th> <th>{{ 'Legende' }}</th> </tr> {% for Point in ListePoint %} <tr> <th>{{ Point.CodeSd }}</th> <th>{{ Point.Id }}</th> <th>{{ Point.Template }}</th> <th>{{ Point.Serveur }}</th> <th>{{ Point.Chemin }}</th> <th>{{ Point.Mini }}</th> <th>{{ Point.Maxi }}</th> <th>{{ Point.Increment }}</th> <th>{{ Point.titre }}</th> <th>{{ Point.Legende }}</th> <th><a href="{{ path('site_point_modifier', { 'id' : Point.id }) }}" target="__blank" >Modifier</a> </th> <th><a href="{{ path('site_point_supprimer', { 'id':Point.Id }) }}" name="{{Point.Id}}">Supprimer</a></th> {% else %} <li>Pas de code SD</li> {% endfor %} </TABLE> {% endblock %}
Je pense que c'est un truc tout bête mais je vois pas du tout.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 {% extends "SitePointBundle::layout.html.twig" %} {% block title %} Accueil - {{ parent() }} {% endblock %} {% block recherche %} <select Id='recherche' > {% for Point in Liste %} <OPTION name='liste' value='{{ Point.CodeSd }}' >{{ Point.CodeSd }} {% endfor %} </select> {% endblock %}
Je vous remercie d'avance
Partager