- commit
- 05f880d7b2f0f56d56f24adae11bbca7d178a4e5
- parent
- ba7c99dc0dc194ef2ebcfe5b1c1c482de959709f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2021-01-25 18:28
adapt to bootstrap5
Diffstat
| M | README.md | 2 | +- |
| M | django_bs/templates/bs/field.html | 18 | +++++++----------- |
| D | django_bs/templates/django/forms/widgets/file.html | 1 | - |
| M | django_bs/templates/django/forms/widgets/multiwidget.html | 4 | ++-- |
| M | django_bs/templates/django/forms/widgets/select.html | 2 | +- |
| M | django_bs/templatetags/bootstrap.py | 2 | +- |
6 files changed, 12 insertions, 17 deletions
diff --git a/README.md b/README.md
@@ -57,7 +57,7 @@ Differences to django-bootstrap4 57 57 would otherwise not be available in the widget templates. 58 58 - Concentrates on forms fields and does therefore not include some others 59 59 features.60 -1 - Uses `small.text-danger` instead of `.invalid-feedback` as it does not-1 60 - Uses `.form-text.text-danger` instead of `.invalid-feedback` as it does not 61 61 depend on DOM location. (see also [twbs/bootstrap\#29439]) 62 62 - Does not use `.is-valid` because I find it confusing with server-side 63 63 rendering.
diff --git a/django_bs/templates/bs/field.html b/django_bs/templates/bs/field.html
@@ -2,28 +2,24 @@ 2 2 {% if check %} 3 3 {{ field }} 4 4 {% if show_label %}5 -1 <label for="{{ field.id_for_label }}" class="form-check-label {% ifequal show_label 'sr-only' %}sr-only{% endifequal %}">{{ field.label }}</label>-1 5 <label for="{{ field.id_for_label }}" class="form-check-label {% ifequal show_label 'sr-only' %}visually-hidden{% endifequal %}">{{ field.label }}</label> 6 6 {% endif %} 7 7 {% else %} 8 8 {% if show_label %} 9 9 {% if fieldset %}10 -1 <legend class="h6 {% ifequal show_label 'sr-only' %}sr-only{% endifequal %}">{{ field.label }}</legend>-1 10 <legend class="form-label {% ifequal show_label 'sr-only' %}visually-hidden{% endifequal %}">{{ field.label }}</legend> 11 11 {% else %}12 -1 <label {% ifequal show_label 'sr-only' %}class="sr-only"{% endifequal %} for="{{ field.id_for_label }}">{{ field.label }}</label>-1 12 <label class="form-label {% ifequal show_label 'sr-only' %}visually-hidden{% endifequal %}" for="{{ field.id_for_label }}">{{ field.label }}</label> 13 13 {% endif %} 14 14 {% endif %} 15 15 {% if addon_before or addon_after %} 16 16 <div class="input-group"> 17 17 {% if addon_before %}18 -1 <div class="input-group-prepend">19 -1 <span class="input-group-text">{{ addon_before }}</span>20 -1 </div>-1 18 <span class="input-group-text">{{ addon_before }}</span> 21 19 {% endif %} 22 20 {{ field }} 23 21 {% if addon_after %}24 -1 <div class="input-group-append">25 -1 <span class="input-group-text">{{ addon_after }}</span>26 -1 </div>-1 22 <span class="input-group-text">{{ addon_after }}</span> 27 23 {% endif %} 28 24 </div> 29 25 {% else %} @@ -31,9 +27,9 @@ 31 27 {% endif %} 32 28 {% endif %} 33 29 {% if field.help_text %}34 -1 <small class="form-text text-muted">{{ field.help_text }}</small>-1 30 <div class="form-text">{{ field.help_text }}</div> 35 31 {% endif %} 36 32 {% for error in field.errors %}37 -1 <small class="form-text text-danger">{{ error }}</small>-1 33 <div class="form-text text-danger">{{ error }}</div> 38 34 {% endfor %} 39 35 </{{ fieldset|yesno:'fieldset,div' }}>
diff --git a/django_bs/templates/django/forms/widgets/file.html b/django_bs/templates/django/forms/widgets/file.html
@@ -1 +0,0 @@1 -1 <input type="{{ widget.type }}" name="{{ widget.name }}" class="form-control-file" {% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}>
diff --git a/django_bs/templates/django/forms/widgets/multiwidget.html b/django_bs/templates/django/forms/widgets/multiwidget.html
@@ -1,6 +1,6 @@1 -1 <fieldset class="form-row">-1 1 <fieldset class="row g-3"> 2 2 {% for widget in widget.subwidgets %}3 -1 <div class="col-sm {% if not forloop.last %}mb-2 mb-sm-0{% endif %}">-1 3 <div class="col-sm"> 4 4 {% include widget.template_name %} 5 5 </div> 6 6 {% endfor %}
diff --git a/django_bs/templates/django/forms/widgets/select.html b/django_bs/templates/django/forms/widgets/select.html
@@ -1,4 +1,4 @@1 -1 <select name="{{ widget.name }}" class="form-control"{% include "django/forms/widgets/attrs.html" %}>-1 1 <select name="{{ widget.name }}" class="form-select"{% include "django/forms/widgets/attrs.html" %}> 2 2 {% for group_name, group_choices, group_index in widget.optgroups %} 3 3 {% if group_name %} 4 4 <optgroup label="{{ group_name }}">
diff --git a/django_bs/templatetags/bootstrap.py b/django_bs/templatetags/bootstrap.py
@@ -48,7 +48,7 @@ def bootstrap_field( 48 48 addon_before=None, 49 49 addon_after=None, 50 50 show_label=True,51 -1 form_group_class='form-group',-1 51 form_group_class='mb-3', 52 52 ): 53 53 widget = boundfield.field.widget 54 54 is_check = getattr(widget, 'input_type', None) in ['checkbox', 'radio']