django-bs

Bootstrap integration for django using widget templates
git clone https://git.ce9e.org/django-bs.git

commit
bad4c1fda498aa5f2fdf4c194f4f4d8ae28b3bf2
parent
8feeea5b7f88be1565be06ceb7100b007072389b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-09-15 14:40
breaking: treat show_label=False as sr-only

django-bootstrap5:

- True -> shown
- False|'sr-only' -> visually hidden
- 'skip' -> skipped

old behavior:

- True -> shown
- 'sr-only' -> visually hidden
- False -> skipped

new behavior:

- True -> shown
- False -> visually hidden

Consistent behavior of True/False is IMHO what is most important here.

See also: https://github.com/zostera/django-bootstrap4/issues/115

Diffstat

M django_bs/templates/bs/field.html 14 +++++---------

1 files changed, 5 insertions, 9 deletions


diff --git a/django_bs/templates/bs/field.html b/django_bs/templates/bs/field.html

@@ -1,16 +1,12 @@
    1     1 <{{ fieldset|yesno:'fieldset,div' }} class="{{ form_group_class }} {% if check %}form-check{% endif %}">
    2     2     {% if check %}
    3     3         {{ field }}
    4    -1         {% if show_label %}
    5    -1             <label for="{{ field.id_for_label }}" class="form-check-label {% if show_label == 'sr-only' %}visually-hidden{% endif %}">{{ field.label }}</label>
    6    -1         {% endif %}
   -1     4         <label for="{{ field.id_for_label }}" class="form-check-label {% if not show_label %}visually-hidden{% endif %}">{{ field.label }}</label>
    7     5     {% else %}
    8    -1         {% if show_label %}
    9    -1             {% if fieldset %}
   10    -1                 <legend class="form-label fs-6 {% if show_label == 'sr-only' %}visually-hidden{% endif %}">{{ field.label }}</legend>
   11    -1             {% else %}
   12    -1                 <label class="form-label {% if show_label == 'sr-only' %}visually-hidden{% endif %}" for="{{ field.id_for_label }}">{{ field.label }}</label>
   13    -1             {% endif %}
   -1     6         {% if fieldset %}
   -1     7             <legend class="form-label fs-6 {% if not show_label %}visually-hidden{% endif %}">{{ field.label }}</legend>
   -1     8         {% else %}
   -1     9             <label class="form-label {% if not show_label %}visually-hidden{% endif %}" for="{{ field.id_for_label }}">{{ field.label }}</label>
   14    10         {% endif %}
   15    11         {% if addon_before or addon_after %}
   16    12             <div class="input-group">