From d4928755cd759bce2c4ce44e829d471361de7571 Mon Sep 17 00:00:00 2001 From: colesm Date: Mon, 14 Apr 2025 15:22:50 +0200 Subject: [PATCH] Incident commit avec en plus Form et twig --- src/Form/IncidentType.php | 33 ++++++++++++++++++++++++++++++ templates/incident/index.html.twig | 30 +++++++++++++++++++++++++++ templates/incident/new.html.twig | 11 ++++++++++ 3 files changed, 74 insertions(+) create mode 100644 src/Form/IncidentType.php create mode 100644 templates/incident/index.html.twig create mode 100644 templates/incident/new.html.twig diff --git a/src/Form/IncidentType.php b/src/Form/IncidentType.php new file mode 100644 index 0000000..9bee257 --- /dev/null +++ b/src/Form/IncidentType.php @@ -0,0 +1,33 @@ +add('description', + TextareaType::class) + ->add('employee', EntityType::class, ['class' => Employee::class, 'choice_label' => 'firstname']) +// ->add('incidentType', EntityType::class, ['class' => IncidentType::class, 'choice_label' => 'id']) + ->add('Enregistrer', SubmitType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + // Configure your form options here + ]); + } +} diff --git a/templates/incident/index.html.twig b/templates/incident/index.html.twig new file mode 100644 index 0000000..58bbe65 --- /dev/null +++ b/templates/incident/index.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} + +{% block title %}Incident index{% endblock %} + +{% block body %} +

Incident index

+ + + + + + + + + + {% for incident in incidents %} + + + + + + {% endfor %} + +
IdDescription
{{ incident.id }}{{ incident.description }} + show + edit +
+ + Create new +{% endblock %} diff --git a/templates/incident/new.html.twig b/templates/incident/new.html.twig new file mode 100644 index 0000000..18ff4c1 --- /dev/null +++ b/templates/incident/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Incident{% endblock %} + +{% block body %} +

Create new Incident

+ + {{ form(formNew,{'attr': {'novalidate': 'novalidate'}}) }} + + back to list +{% endblock %}