diff --git a/crispy_bootstrap4/templates/bootstrap4/field.html b/crispy_bootstrap4/templates/bootstrap4/field.html index 76591bf..56fe326 100644 --- a/crispy_bootstrap4/templates/bootstrap4/field.html +++ b/crispy_bootstrap4/templates/bootstrap4/field.html @@ -11,7 +11,7 @@ {% endif %} <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="{% if not field|is_checkbox %}form-group{% if 'form-horizontal' in form_class %} row{% endif %}{% else %}{%if use_custom_control%}{% if tag != 'td' %}custom-control {%endif%} custom-checkbox{% else %}form-check{% 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 %} - {# not field|is_radioselect in row below can be removed once Django 3.2 is no longer supported #} + {# not field|is_radioselect in row below can be removed once Django 3.2 is no longer supported #} @@ -26,8 +26,12 @@ {% endif %} {% if not field|is_checkboxselectmultiple and not field|is_radioselect %} - {% if field|is_checkbox and form_show_labels %} - {%if use_custom_control%} + {% if field|is_checkbox %} + {% if use_custom_control %} + {% if tag == 'td' %} +
+ {% endif %} + {% if field.errors %} {% crispy_field field 'class' 'custom-control-input is-invalid' %} {% else %} @@ -41,9 +45,16 @@ {% endif %} {% endif %} {% include 'bootstrap4/layout/help_text_and_errors.html' %} + {% if use_custom_control and tag == 'td' %} +
+ {% endif %} {% elif field|is_file and use_custom_control %} {% include 'bootstrap4/layout/field_file.html' %} {% else %} @@ -55,13 +66,13 @@ {% crispy_field field 'class' 'custom-select' %} {% endif %} {% elif field|is_file %} - {% if field.errors %} + {% if field.errors %} {% crispy_field field 'class' 'form-control-file is-invalid' %} {% else %} {% crispy_field field 'class' 'form-control-file' %} {% endif %} {% else %} - {% if field.errors %} + {% if field.errors %} {% crispy_field field 'class' 'form-control is-invalid' %} {% else %} {% crispy_field field 'class' 'form-control' %} diff --git a/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html b/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html index 0c851d2..4df52f7 100644 --- a/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html +++ b/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html @@ -21,17 +21,19 @@
-
- +
+ +
-
- +
+ +
@@ -39,17 +41,19 @@
-
- +
+ +
-
- +
+ +