diff --git a/crispy_bootstrap5/templates/bootstrap5/field.html b/crispy_bootstrap5/templates/bootstrap5/field.html
index 8312e9b..bcf471a 100644
--- a/crispy_bootstrap5/templates/bootstrap5/field.html
+++ b/crispy_bootstrap5/templates/bootstrap5/field.html
@@ -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" %}
{% endif %}
diff --git a/crispy_bootstrap5/templates/bootstrap5/table_inline_formset.html b/crispy_bootstrap5/templates/bootstrap5/table_inline_formset.html
index 097ebb3..e1b6a0a 100644
--- a/crispy_bootstrap5/templates/bootstrap5/table_inline_formset.html
+++ b/crispy_bootstrap5/templates/bootstrap5/table_inline_formset.html
@@ -33,7 +33,7 @@
{% 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 %}
@@ -44,7 +44,7 @@
{% 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 %}
{% endfor %}
diff --git a/tests/test_layout.py b/tests/test_layout.py
index fc2f551..928b0ed 100644
--- a/tests/test_layout.py
+++ b/tests/test_layout.py
@@ -688,3 +688,19 @@ def test_help_text_no_escape():
else:
expected = "help_text_escape.html"
assert parse_form(form) == parse_expected(expected)
+
+
+def test_tag_context():
+ SampleFormSet = formset_factory(SampleForm, extra=3)
+ formset = SampleFormSet()
+ formset.helper = FormHelper()
+ context = {
+ "form": formset,
+ "tag": "User defined tag in context",
+ }
+
+ response = render(
+ request=None, template_name="crispy_render_template.html", context=context
+ )
+
+ assert response.content.count(b"User defined tag in context") == 0