From 668e66db094f7ddec12cd29cf0c7705788b5f1a8 Mon Sep 17 00:00:00 2001 From: David Smith <39445562+smithdc1@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:30:50 +0000 Subject: [PATCH] Used
and to group related inputs. (#158) --- .../templates/bootstrap5/field.html | 7 +- .../layout/checkboxselectmultiple_inline.html | 6 +- .../bootstrap5/layout/radioselect_inline.html | 6 +- tests/results/checkboxes.html | 30 ++++--- tests/results/inline_checkboxes.html | 30 ++++--- tests/results/inline_checkboxes_failing.html | 4 +- .../inline_checkboxes_failing_lt50.html | 4 +- tests/results/inline_radios.html | 22 ++--- tests/results/inline_radios_failing.html | 4 +- tests/results/inline_radios_failing_lt50.html | 4 +- tests/results/radio.html | 88 +++++++++---------- tests/results/test_grouped_checkboxes.html | 46 +++++----- .../test_grouped_checkboxes_failing.html | 50 ++++++----- .../test_grouped_checkboxes_failing_lt50.html | 50 ++++++----- tests/results/test_grouped_radios.html | 30 ++++--- .../results/test_grouped_radios_failing.html | 48 +++++----- .../test_grouped_radios_failing_lt50.html | 48 +++++----- tests/results/test_switch_horizontal.html | 2 +- tests/test_layout_objects.py | 6 ++ tests/test_tags.py | 2 +- 20 files changed, 263 insertions(+), 224 deletions(-) diff --git a/crispy_bootstrap5/templates/bootstrap5/field.html b/crispy_bootstrap5/templates/bootstrap5/field.html index 8d34aec..44af057 100644 --- a/crispy_bootstrap5/templates/bootstrap5/field.html +++ b/crispy_bootstrap5/templates/bootstrap5/field.html @@ -11,9 +11,11 @@ {% endif %} <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="{% if field|is_checkbox and form_show_labels %}form-check{% else %}mb-3{% 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 %} - + {% endif %} {% if field|is_checkboxselectmultiple or field|is_radioselect %} @@ -58,6 +60,7 @@ {% if field_class %}{% endif %} {% endif %} {% endif %} + {% if field.use_fieldset and field.label and form_show_labels %}
{% endif %} {% if field|is_checkbox and tag != "td" %} {% if label_class %} diff --git a/crispy_bootstrap5/templates/bootstrap5/layout/checkboxselectmultiple_inline.html b/crispy_bootstrap5/templates/bootstrap5/layout/checkboxselectmultiple_inline.html index a494991..1057583 100644 --- a/crispy_bootstrap5/templates/bootstrap5/layout/checkboxselectmultiple_inline.html +++ b/crispy_bootstrap5/templates/bootstrap5/layout/checkboxselectmultiple_inline.html @@ -4,11 +4,13 @@
{% if field.label %} - + {% endif %} {% include 'bootstrap5/layout/radio_checkbox_select.html' %} + {% if field.label %}{% endif %}
{% endif %} diff --git a/crispy_bootstrap5/templates/bootstrap5/layout/radioselect_inline.html b/crispy_bootstrap5/templates/bootstrap5/layout/radioselect_inline.html index a494991..1057583 100644 --- a/crispy_bootstrap5/templates/bootstrap5/layout/radioselect_inline.html +++ b/crispy_bootstrap5/templates/bootstrap5/layout/radioselect_inline.html @@ -4,11 +4,13 @@
{% if field.label %} - + {% endif %} {% include 'bootstrap5/layout/radio_checkbox_select.html' %} + {% if field.label %}{% endif %}
{% endif %} diff --git a/tests/results/checkboxes.html b/tests/results/checkboxes.html index 2b7198d..addfa5b 100644 --- a/tests/results/checkboxes.html +++ b/tests/results/checkboxes.html @@ -1,19 +1,21 @@
- -
-
- +
+ Checkboxes* +
+
+ +
+
+ +
+
+ +
-
- -
-
- -
-
+
\ No newline at end of file diff --git a/tests/results/inline_checkboxes.html b/tests/results/inline_checkboxes.html index c5a0e30..d72a6de 100644 --- a/tests/results/inline_checkboxes.html +++ b/tests/results/inline_checkboxes.html @@ -1,19 +1,21 @@
- -
-
- - +
+ Checkboxes* +
+
+ + +
+
+ + +
+
+ + +
-
- - -
-
- - -
-
+
diff --git a/tests/results/inline_checkboxes_failing.html b/tests/results/inline_checkboxes_failing.html index 589a9e8..e9c7e86 100644 --- a/tests/results/inline_checkboxes_failing.html +++ b/tests/results/inline_checkboxes_failing.html @@ -1,6 +1,7 @@
- +
+ Checkboxes*
@@ -16,5 +17,6 @@

This field is required.

+
diff --git a/tests/results/inline_checkboxes_failing_lt50.html b/tests/results/inline_checkboxes_failing_lt50.html index fa07556..99d36a8 100644 --- a/tests/results/inline_checkboxes_failing_lt50.html +++ b/tests/results/inline_checkboxes_failing_lt50.html @@ -1,6 +1,7 @@
- +
+ Checkboxes*
@@ -16,5 +17,6 @@

This field is required.

+
diff --git a/tests/results/inline_radios.html b/tests/results/inline_radios.html index 1d19b89..8184940 100644 --- a/tests/results/inline_radios.html +++ b/tests/results/inline_radios.html @@ -1,15 +1,17 @@
- -
-
- - +
+ Inline radios* +
+
+ + +
+
+ + +
-
- - -
-
+
diff --git a/tests/results/inline_radios_failing.html b/tests/results/inline_radios_failing.html index 7b7c000..4a21f2f 100644 --- a/tests/results/inline_radios_failing.html +++ b/tests/results/inline_radios_failing.html @@ -1,6 +1,7 @@
- +
+ Inline radios*
@@ -12,5 +13,6 @@

This field is required.

+
diff --git a/tests/results/inline_radios_failing_lt50.html b/tests/results/inline_radios_failing_lt50.html index 28d8b4c..db29286 100644 --- a/tests/results/inline_radios_failing_lt50.html +++ b/tests/results/inline_radios_failing_lt50.html @@ -1,6 +1,7 @@
- +
+ Inline radios*
@@ -12,5 +13,6 @@

This field is required.

+
diff --git a/tests/results/radio.html b/tests/results/radio.html index df9ae8a..70fe3b5 100644 --- a/tests/results/radio.html +++ b/tests/results/radio.html @@ -1,48 +1,48 @@
- -
-
- - -
-
- - -
-
- - -
-
+
+ Radio* +
+
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/tests/results/test_grouped_checkboxes.html b/tests/results/test_grouped_checkboxes.html index 852ece7..a3434ad 100644 --- a/tests/results/test_grouped_checkboxes.html +++ b/tests/results/test_grouped_checkboxes.html @@ -1,25 +1,27 @@
-
-
Audio -
-
Video -
-
-
-
-
- help -
+
+
+ Checkbox select multiple* +
Audio +
+
Video +
+
+
+
+
+ help +
+
diff --git a/tests/results/test_grouped_checkboxes_failing.html b/tests/results/test_grouped_checkboxes_failing.html index ebd336e..8986753 100644 --- a/tests/results/test_grouped_checkboxes_failing.html +++ b/tests/results/test_grouped_checkboxes_failing.html @@ -1,28 +1,30 @@
-
-
Audio -
-
Video -
-
-
-

This field is - required.

+
+
+ Checkbox select multiple* +
Audio +
+
Video +
+
+
+

This field is + required.

+
-
-
- help -
+
+ help +
+
diff --git a/tests/results/test_grouped_checkboxes_failing_lt50.html b/tests/results/test_grouped_checkboxes_failing_lt50.html index 3df66b4..2783205 100644 --- a/tests/results/test_grouped_checkboxes_failing_lt50.html +++ b/tests/results/test_grouped_checkboxes_failing_lt50.html @@ -1,28 +1,30 @@
-
-
Audio -
-
Video -
-
-
-

This field is - required.

+
+
+ Checkbox select multiple* +
Audio +
+
Video +
+
+
+

This field is + required.

+
-
-
- help -
+
+ help +
+
diff --git a/tests/results/test_grouped_radios.html b/tests/results/test_grouped_radios.html index 9a20148..8fc8e8e 100644 --- a/tests/results/test_grouped_radios.html +++ b/tests/results/test_grouped_radios.html @@ -1,17 +1,19 @@
-
-
Audio -
-
Video -
-
-
-
+
+
+ Radio* +
Audio +
+
Video +
+
+
+
+
\ No newline at end of file diff --git a/tests/results/test_grouped_radios_failing.html b/tests/results/test_grouped_radios_failing.html index 947240c..9fcd598 100644 --- a/tests/results/test_grouped_radios_failing.html +++ b/tests/results/test_grouped_radios_failing.html @@ -1,25 +1,27 @@
-
-
Audio -
-
Video -
-
-
-

This field is - required.

-
-
-
+
+
+ Radio* +
Audio +
+
Video +
+
+
+

This field is + required.

+
+
+
+
\ No newline at end of file diff --git a/tests/results/test_grouped_radios_failing_lt50.html b/tests/results/test_grouped_radios_failing_lt50.html index 4888f75..a1c010e 100644 --- a/tests/results/test_grouped_radios_failing_lt50.html +++ b/tests/results/test_grouped_radios_failing_lt50.html @@ -1,25 +1,27 @@
-
-
Audio -
-
Video -
-
-
-

This field is - required.

-
-
-
+
+
+ Radio* +
Audio +
+
Video +
+
+
+

This field is + required.

+
+
+
+
\ No newline at end of file diff --git a/tests/results/test_switch_horizontal.html b/tests/results/test_switch_horizontal.html index b2886c0..17d3811 100644 --- a/tests/results/test_switch_horizontal.html +++ b/tests/results/test_switch_horizontal.html @@ -7,7 +7,7 @@
- +
diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py index 7432daa..72b3cd8 100644 --- a/tests/test_layout_objects.py +++ b/tests/test_layout_objects.py @@ -636,3 +636,9 @@ def test_modal(self): ) ) assert parse_form(test_form) == parse_expected("modal.html") + + def test_inline_checkboxes(self): + form = CheckboxesSampleForm() + form.helper = FormHelper() + form.helper.layout = InlineRadios("checkboxes") + assert parse_form(form) == parse_expected("inline_checkboxes.html") diff --git a/tests/test_tags.py b/tests/test_tags.py index 0ba29d6..cae9880 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -150,7 +150,7 @@ def test_crispy_filter_with_form(): assert "" not in html assert "id_is_company" in html - assert html.count("