Skip to content

Commit

Permalink
Avoided adding tag to context.
Browse files Browse the repository at this point in the history
"tag" can be a popular name for a queryset and therefore added to context in views. Changed tag to crispy_tag to avoid name conflicts.

Refs django-crispy-forms/django-crispy-forms#830
  • Loading branch information
smithdc1 committed Nov 1, 2023
1 parent 069a6c9 commit 9d1284b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crispy_bootstrap5/templates/bootstrap5/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
{% if field|is_checkbox and tag != "td" %}
{% if field|is_checkbox and crispy_tag != "td" %}
<div class="mb-3{% if 'form-horizontal' in form_class %} row{% endif %}">
{% if label_class %}
<div class="{% for offset in bootstrap_checkbox_offsets %}{{ offset|slice:"7:14" }}{{ offset|slice:"4:7" }}{{ offset|slice:"14:16" }} {% endfor %}{{ field_class }}">
{% endif %}
{% endif %}
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="mb-3{% if field|is_checkbox and form_show_labels %} form-check{% else %}{% if 'form-horizontal' in form_class %} row{% endif %}{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<{% if crispy_tag %}{{ crispy_tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="mb-3{% if field|is_checkbox and form_show_labels %} form-check{% else %}{% if 'form-horizontal' in form_class %} row{% endif %}{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label and not field|is_checkbox and form_show_labels %}
<label {% if field.id_for_label %}for="{{ field.id_for_label }}"{% endif %} class="{% if 'form-horizontal' in form_class %}col-form-label{% else %}form-label{% endif %}{% if label_class %} {{ label_class }}{% endif %}{% if field.field.required %} requiredField{% endif %}">
{{ field.label }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
Expand Down Expand Up @@ -58,8 +58,8 @@
{% if field_class %}</div>{% endif %}
{% endif %}
{% endif %}
</{% if tag %}{{ tag }}{% else %}div{% endif %}>
{% if field|is_checkbox and tag != "td" %}
</{% if crispy_tag %}{{ crispy_tag }}{% else %}div{% endif %}>
{% if field|is_checkbox and crispy_tag != "td" %}
{% if label_class %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<tbody>
<tr class="d-none empty-form">
{% for field in formset.empty_form %}
{% include 'bootstrap5/field.html' with tag="td" form_show_labels=False %}
{% include 'bootstrap5/field.html' with crispy_tag="td" form_show_labels=False %}
{% endfor %}
</tr>

Expand All @@ -44,7 +44,7 @@

<tr>
{% for field in form %}
{% include 'bootstrap5/field.html' with tag="td" form_show_labels=False %}
{% include 'bootstrap5/field.html' with crispy_tag="td" form_show_labels=False %}
{% endfor %}
</tr>
{% endfor %}
Expand Down

0 comments on commit 9d1284b

Please sign in to comment.