From 0d9524f5d2f9c3661067920eefa5a0e5127c4cb4 Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Tue, 6 Oct 2020 15:02:29 +0200 Subject: [PATCH] set Default Nature Task choice correctly --- src/schedule-2.0/src/Controller/TaskController.php | 3 ++- src/schedule-2.0/templates/Project/edit.html.twig | 2 +- src/schedule-2.0/templates/Task/edit.html.twig | 4 ---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/schedule-2.0/src/Controller/TaskController.php b/src/schedule-2.0/src/Controller/TaskController.php index 260bffa..fb27118 100755 --- a/src/schedule-2.0/src/Controller/TaskController.php +++ b/src/schedule-2.0/src/Controller/TaskController.php @@ -53,7 +53,8 @@ class TaskController extends AbstractController // Initialisation de l'enregistrement $em = $this->getDoctrine()->getManager(); $data = new Entity(); - + $defaultnature = $em->getRepository("App:Nature")->findOneBy(['name' => 'Prestation']); + $data->setNature($defaultnature); // Création du formulaire $form = $this->createForm(Form::class,$data,array("mode"=>"submit")); diff --git a/src/schedule-2.0/templates/Project/edit.html.twig b/src/schedule-2.0/templates/Project/edit.html.twig index b99d325..df6c2d3 100755 --- a/src/schedule-2.0/templates/Project/edit.html.twig +++ b/src/schedule-2.0/templates/Project/edit.html.twig @@ -61,7 +61,7 @@ {% endblock %} {% block localjavascript %} -$("#project_customer").addClass("select2entity"); + $("#project_customer").addClass("select2entity"); $(document).ready(function() { $("#project_name").focus(); }); diff --git a/src/schedule-2.0/templates/Task/edit.html.twig b/src/schedule-2.0/templates/Task/edit.html.twig index 4d99524..2bf54ae 100755 --- a/src/schedule-2.0/templates/Task/edit.html.twig +++ b/src/schedule-2.0/templates/Task/edit.html.twig @@ -62,10 +62,6 @@ {% endblock %} {% block localjavascript %} - var defaultsel = 'Prestation'; - $("#task_nature option").filter(function() { - return $(this).text() == defaultsel; - }).prop('selected', true); $(document).ready(function() { $("#task_name").focus();