Repository: django-crispy-forms/django-crispy-forms (language: python)

Issue:
CheckBoxes rendering issues in table_inline_formset.html
* Package version: 1.14.0
* Django version: 3.2
* Python version: 3.9
* Template pack: bootstrap4

### Description:

Checkboxes brake rendering when using table_inline_formset.html (see screenshot below)

![Screenshot 2022-03-29 at 17-06-43 Périodique](https://user-images.githubusercontent.com/124813/160644178-8c416350-50ae-444c-9cdc-7047f66ab071.png)

#### Actual HTML generated : 
```html
<td id="div_id_edition_set-0-vivant" class="custom-control custom-checkbox">
    <div>
        <input type="checkbox" name="edition_set-0-vivant" class="checkboxinput" id="id_edition_set-0-vivant" checked="">
    </div>
</td>
```

Removing the custom-control class in checkbox's `<td>` seems to fix the rendering issue. It can be done in crispy_forms/templates/bootstrap4/field.html line 12 by removing "custom-control" in this condition `{%if use_custom_control%}custom-control custom-checkbox{% else %}form-check{% endif %}`

#### Expected Result : 

![Screenshot 2022-03-29 at 17-06-15 Périodique](https://user-images.githubusercontent.com/124813/160646745-5fbb6cfa-0da9-404b-9aa0-caf5d689fef9.png)

I don't know if this modification brings side effects elsewhere though



Discussion / hints:

Fix patch:
diff --git a/crispy_forms/templates/bootstrap4/field.html b/crispy_forms/templates/bootstrap4/field.html
index 3d1d73a2..8952fc8c 100644
--- a/crispy_forms/templates/bootstrap4/field.html
+++ b/crispy_forms/templates/bootstrap4/field.html
@@ -9,7 +9,7 @@
             <div class="{% for offset in bootstrap_checkbox_offsets %}{{ offset }} {% endfor %}{{ field_class }}">
         {% endif %}
     {% 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%}custom-control custom-checkbox{% else %}form-check{% endif %}{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% 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 #}    
         <label {% if field.id_for_label and not field|is_radioselect %}for="{{ field.id_for_label }}" {% endif %}class="{% if 'form-horizontal' in form_class %}col-form-label {% endif %}{{ label_class }}{% if field.field.required %} requiredField{% endif %}">


Test patch:
diff --git a/crispy_forms/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html b/crispy_forms/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html
new file mode 100644
index 00000000..0c851d25
--- /dev/null
+++ b/crispy_forms/tests/results/bootstrap4/test_layout/test_inline_formset_checkbox.html
@@ -0,0 +1,59 @@
+<form method="post">
+    <div><input type="hidden" name="form-TOTAL_FORMS" value="1" id="id_form-TOTAL_FORMS">
+        <input type="hidden"
+               name="form-INITIAL_FORMS"
+               value="0"
+               id="id_form-INITIAL_FORMS">
+        <input type="hidden" name="form-MIN_NUM_FORMS" value="0" id="id_form-MIN_NUM_FORMS">
+        <input type="hidden"
+               name="form-MAX_NUM_FORMS"
+               value="1000"
+               id="id_form-MAX_NUM_FORMS">
+    </div>
+    <table class="table table-striped table-sm">
+        <thead>
+        <tr>
+            <th for="id_form-0-box_one" class="col-form-label requiredField">box one</th>
+            <th for="id_form-0-box_two" class="col-form-label requiredField">box two</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr class="d-none empty-form">
+            <div class="form-group">
+                <td id="div_id_form-__prefix__-box_one" class="custom-checkbox">
+                    <div>
+                        <input type="checkbox" name="form-__prefix__-box_one" class="checkboxinput form-control"
+                               id="id_form-__prefix__-box_one">
+                    </div>
+                </td>
+            </div>
+            <div class="form-group">
+                <td id="div_id_form-__prefix__-box_two" class="custom-checkbox">
+                    <div>
+                        <input type="checkbox" name="form-__prefix__-box_two" class="checkboxinput form-control"
+                               id="id_form-__prefix__-box_two">
+                    </div>
+                </td>
+            </div>
+        </tr>
+        <tr>
+            <div class="form-group">
+                <td id="div_id_form-0-box_one" class="custom-checkbox">
+                    <div>
+                        <input type="checkbox" name="form-0-box_one" class="checkboxinput form-control"
+                               id="id_form-0-box_one">
+                    </div>
+                </td>
+            </div>
+            <div class="form-group">
+                <td id="div_id_form-0-box_two" class="custom-checkbox">
+                    <div>
+                        <input type="checkbox" name="form-0-box_two" class="checkboxinput form-control"
+                               id="id_form-0-box_two">
+                    </div>
+                </td>
+            </div>
+        </tr>
+        </tbody>
+    </table>
+</form>
diff --git a/crispy_forms/tests/test_layout.py b/crispy_forms/tests/test_layout.py
index 8ce648ef..f4afb9ba 100644
--- a/crispy_forms/tests/test_layout.py
+++ b/crispy_forms/tests/test_layout.py
@@ -817,3 +817,15 @@ def __init__(self, *args, **kwargs):
     context = {"csrf_token": "NotARealToken"}
     html = render_crispy_form(form, context=context)
     assert parse_html(html) == parse_expected("bootstrap4/test_layout/test_fundamentals_example.html")
+
+
+@only_bootstrap4
+def test_table_inline_formset_checkbox(settings):
+    class TestForm(forms.Form):
+        box_one = forms.CharField(label="box one", widget=forms.CheckboxInput())
+        box_two = forms.CharField(label="box two", widget=forms.CheckboxInput())
+
+    formset = formset_factory(TestForm)
+    formset.helper = FormHelper()
+    formset.helper.template = "bootstrap4/table_inline_formset.html"
+    assert parse_form(formset) == parse_expected("bootstrap4/test_layout/test_inline_formset_checkbox.html")