hello, i m a debutant on programming in symfony framework so
I'm coding up a twig template to display a list of cars in a simple HTML table .here is the erreur, that i don t understand what i have to do :
the erreur : Key "Id" for array with keys "0, 1, 2" does not exist in MyAppEspritParcBundle:Voiture:list.html.twig at line 20
the function listAction in the controller :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 function listAction() { $marques=array('BMW','Renault','Fiat'); //list des voitures $voiture=array(array('Id'=>'C2345','serie'=>'176','dateMiseCirculation'=>'01/01/2014','Marque'=>'BMW'), array('Id'=>'A2345','serie'=>'186','dateMiseCirculation'=>'13/01/2015','marque'=>'Renault'), array('Id'=>'W0308','serie'=>'196','dateMiseCirculation'=>'02/11/2012','marque'=>'Fiat')); return $this->render('MyAppEspritParcBundle:Voiture:list.html.twig', array('marques'=>$marques,'voiture'=>$voiture)); }
the twig.html:
any help
Code html : 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 <h2>List des voitures</h2> <table border="1"> <tr> <td>Id</td> <td>Série</td> <td>Date de Mise Circulation</td> <td>Marque</td> </tr> {%for i in voiture %} <tr> <td>{{ voiture.Id }}</td> <td>{{ voiture.serie }}</td> <td>{{ voiture.dateMiseCirculation }}</td> <td>{{ voiture.marque }}</td> </tr> {% endfor %} </table>?
Partager