From 783bbd7aaf24e66fbd65e99d4476133d76a66303 Mon Sep 17 00:00:00 2001 From: S Smith Date: Thu, 17 Oct 2024 19:36:46 -0500 Subject: [PATCH 1/2] Add support for Toggle Radio and Checkbox Signed-off-by: S Smith --- crispy_bootstrap5/bootstrap5.py | 3 +++ .../templates/bootstrap5/layout/toggle.html | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 crispy_bootstrap5/templates/bootstrap5/layout/toggle.html diff --git a/crispy_bootstrap5/bootstrap5.py b/crispy_bootstrap5/bootstrap5.py index afca6f3..61b9c16 100644 --- a/crispy_bootstrap5/bootstrap5.py +++ b/crispy_bootstrap5/bootstrap5.py @@ -31,3 +31,6 @@ def __init__(self, *args, **kwargs): class Switch(Field): template = "bootstrap5/layout/switch.html" + +class Toggle(Field): + template = "bootstrap5/layout/toggle.html" diff --git a/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html b/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html new file mode 100644 index 0000000..475a503 --- /dev/null +++ b/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html @@ -0,0 +1,24 @@ +{% load crispy_forms_filters %} +{% load l10n %} + + + {% for group, options, index in field|optgroups %} + {% if group %}{{ group }}{% endif %} + {% for option in options %} + + + {% if field.errors and forloop.last and not inline_class and forloop.parentloop.last %} + {% include 'bootstrap5/layout/field_errors_block.html' %} + {% endif %} + {% endfor %} + {% endfor %} + + +{% if field.errors and inline_class %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +{% endif %} +{% include 'bootstrap5/layout/help_text.html' %} From bfc2b6bda616fffe44cb41ad08b5441cfffac0ad Mon Sep 17 00:00:00 2001 From: S Smith Date: Thu, 17 Oct 2024 19:51:02 -0500 Subject: [PATCH 2/2] Remove extra character Signed-off-by: S Smith --- crispy_bootstrap5/templates/bootstrap5/layout/toggle.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html b/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html index 475a503..3d86d47 100644 --- a/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html +++ b/crispy_bootstrap5/templates/bootstrap5/layout/toggle.html @@ -6,7 +6,7 @@ {% if group %}{{ group }}{% endif %} {% for option in options %} -