From ba698da2cd1cb660ccbc98ce005bff2fbd0f2e2b Mon Sep 17 00:00:00 2001 From: Adrien Gallou Date: Mon, 3 Aug 2026 13:26:07 +0200 Subject: [PATCH] =?UTF-8?q?correction=20sur=20la=20cr=C3=A9ation=20d'une?= =?UTF-8?q?=20interview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La soumission du formulaire de création d'interview ne fonctionnait pas, on avait l'erreur "Le contrôle de formulaire avec name='interview[questions][0][reponse]'" car le champ requis était caché avec easymde, pour cela on désactive le required, où de toute façon on la validation coté serveur avec le NotBlank. De plus EasyMde était affiché seulement sur la première question (où plutôt sur les questions déjà affichées au chargement de la page, pas quand on ajoutait une question, on fait en sorte de le charger quand on ajoute une question. --- .../Event/Form/InterviewQuestionType.php | 2 +- templates/admin/base_with_header.html.twig | 16 +++++++++++----- .../admin/event/interview/_javascript.html.twig | 5 +++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sources/AppBundle/Event/Form/InterviewQuestionType.php b/sources/AppBundle/Event/Form/InterviewQuestionType.php index 45994ea0d..d7154c5a8 100644 --- a/sources/AppBundle/Event/Form/InterviewQuestionType.php +++ b/sources/AppBundle/Event/Form/InterviewQuestionType.php @@ -36,7 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'rows' => 10, 'class' => 'easymde', ], - 'required' => true, + 'required' => false, 'empty_data' => '', 'constraints' => [ new Assert\NotBlank(), diff --git a/templates/admin/base_with_header.html.twig b/templates/admin/base_with_header.html.twig index debca10cc..30ca54dfb 100644 --- a/templates/admin/base_with_header.html.twig +++ b/templates/admin/base_with_header.html.twig @@ -197,13 +197,19 @@ }); }); + window.initEasyMDE = function(element) { + if (element && !element.easymde) { + element.easymde = new EasyMDE({ + element: element, + spellChecker: false, + hideIcons: ['side-by-side', 'fullscreen', 'check-list'] + }); + } + }; + var easyMdeList = document.getElementsByClassName('easymde'); for (var i = 0; i < easyMdeList.length; i++) { - var easymde = new EasyMDE({ - element:easyMdeList[i], - spellChecker: false, - hideIcons: ['side-by-side', 'fullscreen', 'check-list'] - }); + window.initEasyMDE(easyMdeList[i]); } diff --git a/templates/admin/event/interview/_javascript.html.twig b/templates/admin/event/interview/_javascript.html.twig index d3423dda7..1c7d8bc8c 100644 --- a/templates/admin/event/interview/_javascript.html.twig +++ b/templates/admin/event/interview/_javascript.html.twig @@ -17,6 +17,11 @@ collectionHolder.appendChild(item); + const textarea = item.querySelector('.easymde'); + if (textarea) { + window.initEasyMDE(textarea); + } + addDeletionButton(item, collectionHolder.dataset.index); collectionHolder.dataset.index++; }