From 8835cfc539b359e3c586a6c92cc140a3d30f1ab4 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Wed, 3 Sep 2025 16:04:00 +0200 Subject: [PATCH 1/2] make sure that field errors are always visible Bootstrap sets `display: none` unless the error comes after an invalid field. Fixes #763 and potentially #749 --- .../templates/django_bootstrap5/field_errors.html | 2 +- tests/test_bootstrap_field_input_checkbox.py | 2 +- tests/test_bootstrap_field_input_text.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html b/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html index ab00ed7b..78d6a428 100644 --- a/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html +++ b/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html @@ -1,7 +1,7 @@ {% if field_errors %}
{% for text in field_errors %} -
{{ text }}
+
{{ text }}
{% endfor %}
{% endif %} diff --git a/tests/test_bootstrap_field_input_checkbox.py b/tests/test_bootstrap_field_input_checkbox.py index 0d4e3252..3e929c44 100644 --- a/tests/test_bootstrap_field_input_checkbox.py +++ b/tests/test_bootstrap_field_input_checkbox.py @@ -40,7 +40,7 @@ def test_input_type_checkbox_is_invalid(self): '' '' '
' - '
This field is required.
' + '
This field is required.
' "
" "" "" diff --git a/tests/test_bootstrap_field_input_text.py b/tests/test_bootstrap_field_input_text.py index f2bd9caa..923a2a5e 100644 --- a/tests/test_bootstrap_field_input_text.py +++ b/tests/test_bootstrap_field_input_text.py @@ -44,7 +44,7 @@ def test_input_type_text(self): '' '
' - '
This field is required.
' + '
This field is required.
' "
" "" ), @@ -202,7 +202,7 @@ def test_input_validation_failure(self): '' '
' - '
This field is required.
' + '
This field is required.
' "
" "" "" From 31d323868db8fda95dd363e8601eff01c4cddc9a Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Wed, 3 Sep 2025 16:06:06 +0200 Subject: [PATCH 2/2] render field errors in a separate row inside input-group see https://github.com/zostera/django-bootstrap5/issues/763#issuecomment-3249350281 --- .../templates/django_bootstrap5/field_errors.html | 2 +- tests/test_bootstrap_field_input_checkbox.py | 2 +- tests/test_bootstrap_field_input_text.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html b/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html index 78d6a428..93b2eabd 100644 --- a/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html +++ b/src/django_bootstrap5/templates/django_bootstrap5/field_errors.html @@ -1,5 +1,5 @@ {% if field_errors %} -
+
{% for text in field_errors %}
{{ text }}
{% endfor %} diff --git a/tests/test_bootstrap_field_input_checkbox.py b/tests/test_bootstrap_field_input_checkbox.py index 3e929c44..54c81a3e 100644 --- a/tests/test_bootstrap_field_input_checkbox.py +++ b/tests/test_bootstrap_field_input_checkbox.py @@ -39,7 +39,7 @@ def test_input_type_checkbox_is_invalid(self): '
' '' '' - '
' + '
' '
This field is required.
' "
" "
" diff --git a/tests/test_bootstrap_field_input_text.py b/tests/test_bootstrap_field_input_text.py index 923a2a5e..3daf2365 100644 --- a/tests/test_bootstrap_field_input_text.py +++ b/tests/test_bootstrap_field_input_text.py @@ -43,7 +43,7 @@ def test_input_type_text(self): '' '' - '
' + '
' '
This field is required.
' "
" "
" @@ -201,7 +201,7 @@ def test_input_validation_failure(self): 'foo' '' - '
' + '
' '
This field is required.
' "
" "
"