diff --git a/dsfr/templates/dsfr/form_field_snippets/checkboxselectmultiple_snippet.html b/dsfr/templates/dsfr/form_field_snippets/checkboxselectmultiple_snippet.html index 9e0c1349a..66213be14 100644 --- a/dsfr/templates/dsfr/form_field_snippets/checkboxselectmultiple_snippet.html +++ b/dsfr/templates/dsfr/form_field_snippets/checkboxselectmultiple_snippet.html @@ -22,15 +22,10 @@ {{ field|dsfr_input_class_attr|attr:"type:checkbox" }} {% endif %} {% if field.errors %} -
+
{{ field.errors }}
{% endif %}
- {% if field.errors %} -
- {{ field.errors }} -
- {% endif %} diff --git a/example_app/forms.py b/example_app/forms.py index 61c68901d..74200ffc3 100644 --- a/example_app/forms.py +++ b/example_app/forms.py @@ -82,7 +82,7 @@ class ExampleForm(DsfrBaseForm): widget=forms.RadioSelect, ) - sample_checkbox = forms.ChoiceField( + sample_checkbox = forms.MultipleChoiceField( label="Cases à cocher", required=False, choices=[ @@ -124,7 +124,7 @@ def clean_sample_radio(self): def clean_sample_checkbox(self): sample_checkbox = self.cleaned_data["sample_checkbox"] - if sample_checkbox == ["2"]: + if "3" in sample_checkbox: raise forms.ValidationError("Le troisième choix est interdit") return sample_checkbox