From 91d5fb906a589e7a6d53cde3d35ebee2e58a2095 Mon Sep 17 00:00:00 2001
From: Arthur ZHU
Date: Fri, 10 Jun 2022 15:54:33 +0200
Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20erreurs=20formulaire=20dyna?=
=?UTF-8?q?mique?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/entreprises/forms.py | 13 ++++++++---
app/static/css/entreprises.css | 2 +-
.../entreprises/ajout_correspondants.html | 22 ++++++++++++++++---
.../entreprises/envoi_offre_form.html | 16 +++++++-------
4 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py
index c564b24d4..61d517b7c 100644
--- a/app/entreprises/forms.py
+++ b/app/entreprises/forms.py
@@ -471,6 +471,7 @@ class CorrespondantModificationForm(FlaskForm):
if not self.telephone.data and not self.mail.data:
msg = "Saisir un moyen de contact (mail ou téléphone)"
self.telephone.errors.append(msg)
+ self.mail.errors.append(msg)
validate = False
return validate
@@ -690,7 +691,7 @@ class TaxeApprentissageModificationForm(FlaskForm):
class EnvoiOffreForm(FlaskForm):
responsables = FieldList(
- _build_string_field(
+ StringField(
"Responsable (*)",
render_kw={
"placeholder": "Tapez le nom du responsable de formation",
@@ -703,6 +704,8 @@ class EnvoiOffreForm(FlaskForm):
def validate(self):
validate = True
+ list_select = True
+
if not FlaskForm.validate(self):
validate = False
@@ -718,8 +721,12 @@ class EnvoiOffreForm(FlaskForm):
.first()
)
if responsable is None:
- entry.errors.append("Champ incorrect (selectionnez dans la liste)")
- validate = False
+ validate, list_select = False, False
+
+ if list_select is False:
+ self.responsables.errors.append(
+ "Champ incorrect (selectionnez dans la liste)"
+ )
return validate
diff --git a/app/static/css/entreprises.css b/app/static/css/entreprises.css
index 14c8f2103..45d3f7629 100644
--- a/app/static/css/entreprises.css
+++ b/app/static/css/entreprises.css
@@ -131,7 +131,7 @@
margin-right: 20px;
}
-.title-form {
+.title-form-error {
font-weight: bold;
color: #a94442
}
\ No newline at end of file
diff --git a/app/templates/entreprises/ajout_correspondants.html b/app/templates/entreprises/ajout_correspondants.html
index 487916038..fd0fe64b0 100644
--- a/app/templates/entreprises/ajout_correspondants.html
+++ b/app/templates/entreprises/ajout_correspondants.html
@@ -16,9 +16,10 @@