Bonjour,
Je voudrais faire une page qui affiche plusieurs formulaires en ligne à la suite (afficher toutes les lignes d'un table).
J'arrive correctement à afficher un seul formulaire par page mais je n'arrive pas a tous les afficher sur une seule page.
Il faut bien que je fasse une collection de formulaires ?
Voici le début du code que j'ai écrit je ne sais pas quoi mettre dans le controller,
pour afficher les lignes de ma table indicateurs en mode formulaire.
Merci
AdminIndicateursController.php
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 <?php namespace MeteoApplis\AdminBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use MeteoApplis\AdminBundle\Entity\ConfIndicateurs; use MeteoApplis\AdminBundle\Form\ConfIndicateursType; use MeteoApplis\AdminBundle\Entity\ListeFormulaires; use MeteoApplis\AdminBundle\Form\ListeFormulairesType; class AdminIndicateursController extends Controller { public function indexAction() { $listeForms = new ListeFormulaires(); $form = $this->createForm(new ListeFormulaires(), $listeForms); return $this->render('MeteoApplisAdminBundle:Admin:Indicateurs/indicateurs_details.html.twig', array( 'indicateur' => $indicateur, )); } }
ConfIndicateurs.php
ConfIndicateursType.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 <?php namespace MeteoApplis\AdminBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * MeteoApplis\AdminBundle\Entity\ConfIndicateurs * * @ORM\Table() * @ORM\Entity(repositoryClass="MeteoApplis\AdminBundle\Entity\ConfIndicateursRepository") */ class ConfIndicateurs { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string $etat * * @ORM\Column(name="etat", type="string", length=255) */ private $etat; /** * @ORM\Column(name="path", type="string", length=255, nullable=false) */ public $path; /** * @Assert\File(maxSize="6000000") */ public $file; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set etat * * @param string $etat * @return ConfIndicateurs */ public function setEtat($etat) { $this->etat = $etat; return $this; } /** * Get etat * * @return string */ public function getEtat() { return $this->etat; } /** * Set path * * @param string $path * @return ConfIndicateurs */ public function setPath($path) { $this->path = $path; return $this; } /** * Get path * * @return string */ public function getPath() { return $this->path; } public function getAbsolutePath() { return null === $this->path ? null : $this->getUploadRootDir().'/'.$this->path; } public function getWebPath() { return null === $this->path ? null : $this->getUploadDir().'/'.$this->path; } public function getUploadRootDir() { return __DIR__.'/../../../../web/bundles/meteoapplis/img/etats/'; } public function upload() { if(null === $this->file) return; $this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName()); $this->path = $this->file->getClientOriginalName(); $this->file = null; } }
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 <?php namespace MeteoApplis\AdminBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class ConfIndicateursType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('etat') ->add('file') ; } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'MeteoApplis\AdminBundle\Entity\ConfIndicateurs' )); } public function getName() { return 'meteoapplis_adminbundle_confindicateurstype'; } }
ListeFormulaires.php
ListeFormulairesType.php
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
41
42
43
44 <?php namespace MeteoApplis\AdminBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * MeteoApplis\AdminBundle\Entity\ListeFormulaires * * @ORM\Table() * @ORM\Entity(repositoryClass="MeteoApplis\AdminBundle\Entity\ListeFormulairesRepository") */ class ListeFormulaires { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var integer $listeForms */ private $listeForms; public function __construct() { $this->listeForms = new ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } }
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 <?php namespace MeteoApplis\AdminBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class ListeFormulairesType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('listeForms', 'collection', array('type' => new ConfIndicateurs()); ; } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'MeteoApplis\AdminBundle\Entity\ListeFormulaires' )); } public function getName() { return 'meteoapplis_adminbundle_listeformulairestype'; } }
Partager