From 453fb4381ab5d8bd45a2f45175af594b60f7cb6f Mon Sep 17 00:00:00 2001 From: "victor.soulier" Date: Fri, 17 Nov 2023 09:30:42 +0100 Subject: [PATCH] ADD : vue create, difficulte depuis db --- project/src/controller/FrontController.php | 18 ++++++++++---- project/src/templates/create.html | 28 +++++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/project/src/controller/FrontController.php b/project/src/controller/FrontController.php index edb5ea6..12b04e6 100644 --- a/project/src/controller/FrontController.php +++ b/project/src/controller/FrontController.php @@ -108,19 +108,27 @@ class FrontController { global $twig; $listJeu = (new \model\JeuGateway($this->con))->getAll(); - $dVueCreate = []; + $listDifficulte = (new \model\DifficulteGateway($this->con))->getAll(); + + $dVueCreateJeu = []; foreach($listJeu as $jeu){ - $dVueCreate[] = ['id' => $jeu->getId(), 'nom' => $jeu->getNom()]; + $dVueCreateJeu[] = ['id' => $jeu->getId(), 'nom' => $jeu->getNom()]; } - echo $twig->render('create.html', ['dVueCreate' => $dVueCreate]); + + $dVueCreateDifficulte = []; + foreach($listDifficulte as $difficulte){ + $dVueCreateDifficulte[] = ['id' => $difficulte->getId(), 'libelle' => $difficulte->getLibelle()]; + } + + echo $twig->render('create.html', ['dVueCreate' => ["jeux" => $dVueCreateJeu, "difficultes" => $dVueCreateDifficulte]]); } public function ValidationFormulaire(array &$dVueErreur, array &$dVue) { global $twig; - $game = $_POST['game'] ?? ''; - $difficulty = $_POST['difficulty'] ?? ''; + $game = $_POST['jeu'] ?? ''; + $difficulty = $_POST['difficulte'] ?? ''; \config\Validation::val_form($game, $difficulty, $dVueErreur); $dVue['info'] = "Jeu '$game' créé avec la difficulté $difficulty"; diff --git a/project/src/templates/create.html b/project/src/templates/create.html index 0b34612..e5bd518 100644 --- a/project/src/templates/create.html +++ b/project/src/templates/create.html @@ -28,18 +28,28 @@
Mini-jeux disponibles {% if dVueCreate is defined %} - {% for value in dVueCreate %} -
- - -
- {% endfor %} - {% endif %} + {% if dVueCreate["jeux"] is defined %} + {% for value in dVueCreate["jeux"] %} +
+ + +
+ {% endfor %} + {% endif %}
+ + {% if dVueCreate["difficultes"] is defined %} + + + {% endif %} - - + {% endif %} +