Bonjour,

Je travaille sur une interface de gestion des droits, j'ai un formulaire avec les champs profil,statut et access.
Les champs profils et statuts sont des liste déroulantes d'entités et le champ access est de type texte (L=lecture,M=modification,V=validation").
En fait chaque profil a un statut et pour chaque couple profil,satut on a un accès (L,M ou V) .
Je veux afficher un tableau à 2 dimensions profil/statut avec les accès dans les cases à la bonne position.
Le problème est que j'affiche à la suite mes valeurs d'accès mais pas dans les bonnes cases du tableau du twig.
Pouvez me donner des solutions sur la façon de coder les boucles dans le twig et le controller?

Voici mes bouts de codes:

mon form du twig:

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
<form action="{{ path('modifierdroits') }}" method="post" {{ form_enctype(form) }} novalidate="novalidate" >
 
		{# Les erreurs générales du formulaire. #}
 
               {{ form_start(form) }}
		   <div>
				<table>
					<tr>
						<td> {{ form_label(form.profils) }} </td>
						<td> {{ form_errors(form.profils) }} </td>
						<td> {{ form_widget(form.profils) }} </td>
 
					</tr>
 
					<tr>
						<td> {{ form_label(form.statuts) }} </td>
						<td> {{ form_errors(form.statuts) }} </td>
						<td> {{ form_widget(form.statuts) }} </td>
 
					</tr>
					<tr>
						<td> {{ form_label(form.access) }} </td>
						<td> {{ form_errors(form.access) }} </td>
						<td> {{ form_widget(form.access) }} </td>
 
					</tr>
 
					</table>
 
					{{ form_widget(form.save, { 'label': 'Valider' }) }}
 
		        </div>
 
				<div id="page" class="table_droits">
 
				<table>
				<tr>
				<td></td>
			  {% for  statut in statuts %}
			  <td>{{ statut.libelle }} </td>
			  {% endfor %}
			   </tr>
 
 
			{% for  profil in profils %}
 
			<tr>
			  <td>{{ profil.libelle }} </td>
			  <td>
			</tr>
			{% endfor %}
 
			  {%  for profil in droits %}
			      <tr>
			     {%  for statuts in profil %}
 
			     <td>{{ statuts }} </td>
 
				 {% endfor %}
				<tr>
 
			{% endfor %}			
 
				</table>
				</div>				
 
			{{ form_end(form) }}
 
		</form>

Mon bout de code de mon controller:

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
public function modifierdroitsAction(Request $request) 
	/* Affiche le formulaire pour ajouter un utilisateur */
	{
		$droitsprofil= new GestionDroitsApplication();
		/*$profil = new Profil();
		$droitsprofil->addProfil($profil);*/
 
		//récupération des profils en bdd
		$form = $this->createForm(new GestionDroitsApplicationType, $droitsprofil);
		$em = $this->getDoctrine()->getManager();
		$dql = "SELECT b FROM MonprojetTestBundle:Profil b";
		$query = $em->createQuery($dql);
		$profils = $query->getArrayResult();
 
                // de même pour les statuts
		$em2 = $this->getDoctrine()->getManager();
		$dql2 = "SELECT s FROM MontprojetTestBundle:Statut s";
		$query2 = $em2->createQuery($dql2);
		$statuts = $query2->getArrayResult();
 
               // récupération des objets d'entités GestionDroitsApplication
	     $repository = $this->getDoctrine() ->getManager()->getRepository('MontprojetTestBundle:GestionDroitsApplication');
             $listedroits = $repository->findAll();
 
 
 
 
            $tab1=array();
 
 
 
	foreach($listedroits as $droits)
      {
 
          echo $droits->getProfils()->getLibelle();
		  echo $droits->getStatuts()->getLibelle();
 
 
 
		  		  $tab1[$droits->getProfils()->getId()][$droits->getStatuts()->getId()]=$droits->getAccess();
 
 
 
 
 
 
 
 
		  //$tab1[$droits->getProfils()->getLibelle()][$droits->getStatuts()->getLibelle()]=$droits->getAccess();
      }
 
 
 
		$request = $this->get('request');
		if ($request->getMethod() == 'POST') {
			$form->bind($request);
 
			if ($form->isValid()) {
				$em = $this->getDoctrine()->getManager();
				$em->persist($droitsprofil);
				$em->flush();
 
				$this->get('session')->getFlashBag()->add('info', 'Technicien ajouté');
 
				return $this->redirect($this->generateUrl('pagetest'));
			}
		}
 
		return $this->render('MontprojetTestBundle:Default:gestiondroitsapplication.html.twig', array('form' => $form->createView(),'statuts'=>$statuts,'profils' => $profils,'droits' => $tab1));	
 
	}

Merci d'avance