Bonjour,
J'ai un écran qui affiche tous les statuts de ma base et sur chacun, j'ai un lien pour afficher le détail de ce statut.
mon ChantierController attends quelque chose de la forme localhost:8000/statut/4 pour une route définie à /statut/{id}
Les liens que j'ai en survol sont de la forme localhost:8000/statut/{id}?id=4 class= ce qui évidemment ne fait pas mon affaire, j'ai fouillé partout et je ne comprend pas d'où cela peut venir, je débute.
Si vous pouvez jeter un oeil et me dire ce qui ne va pas, merci d'avance.
Je vous joint : Base.html.twig, statuts_voir.html.twig, statut_voir.html.twig et ChantierController.php
src/Controller/ChantierController.php
base.html.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
70
71 <?php // src/Controller/ChantierController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use App\Entity\Chantier; use App\Entity\Statut; use App\Repository\ChantierRepository; use App\Repository\StatutRepository; class ChantierController extends AbstractController { /** * @Route("/", name="home") */ public function home() { return $this->render('base.html.twig'); } /** * @Route("/statut", name="statuts_voir") */ public function statuts_voir(StatutRepository $em) { // On récupére tous les statuts $statuts = $em->findAll(); return $this->render('chantier/voirStatuts.html.twig', [ 'statuts' => $statuts ]); } /** * @Route("/statut/{$id}", name="statut_voir") */ public function statut_voir(Statut $statut) { //$em = $this->getDoctrine()->getManager(); // On récupère un statut // $statut = $em->getRepository('Statut')->find($id); return $this->render('chantier/voirStatut.html.twig', [ 'statut' => $statut ]); } /** * @Route("/chantier", name="chantier") */ public function index() { return $this->render('chantier/index.html.twig', [ 'controller_name' => 'ChantierController', ]); } /** * @Route("/chantier/{id}", name="chantier_voir") */ public function chantier_voir(Chantier $chantier) // visualisation d'un chantier { return $this->render('chantier/voir.html.twig', [ 'chantier' => $chantier ]); } }
Code twig : 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 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://bootswatch.com/4/flatly/bootstrap.min.css"> {% block stylesheets %} {% endblock %} </head> <body> <nav class="navbar navbar-expand-lg navbar-dark bg-primary"> <a class="navbar-brand" href="{{ path('home') }}">OD/Fibres/Infra</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarColor01"> <ul class="navbar-nav mr-auto"> <!-- Dropdown Admin --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">Admin</a> <div class="dropdown-menu"> <a class="dropdown-header">Chantiers</a> <a class="dropdown-item" href="{{ path('statuts_voir') }}">Gérer les statuts</a> <a class="dropdown-item" href="#">Créer un chantier</a> <a class="dropdown-item" href="#">Modifier un chantier</a> </div> </li> <!-- Fin du Dropdown Admin --> <li class="nav-item"> <a class="nav-link" href="#">Admin</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Features</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Pricing</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="text" placeholder="Search"> <button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button> </form> </div> </nav> {% block gauche %} {% endblock %} {% block javascripts %} {% endblock %} </body> </html>
voirStatuts.html.twig
Code Twig : 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 {% extends 'base.html.twig' %} {% block gauche %} <ul> {% for statut in statuts %} <statut> <li> <p> Ecrit le {{ statut.dateCreation | date('d/m/Y') }} à {{ statut.dateCreation | date('H:i') }}</p> <a href="{{ path('statut_voir', {'id': statut.id}) }} class="btn btn-primary""> {{ statut.libelle }} </a> </li> </statut> {% endfor %} </ul> <a href="{{ path('home') }}" class="btn btn-info" role="button">Boutton home</a> <a href="{{ path('statut_voir') }}" class="btn btn-info" role="button">Boutton voir</a> {% endblock %} {% block centre %} {% endblock %} {% block droit %} {% endblock %}
voirStatut.html.twig
Code twig : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 {% extends 'base.html.twig' %} {% block gauche %} {% endblock %} {% block centre %} {{ statut.libelle }} créé le {{ statut.dateCreation |date('d/m/Y') }} {% endblock %} {% block droit %} {% endblock %}
Partager