Skip to content

Commit 53549ce

Browse files
authored
Merge pull request stephenmcd#219 from bentimms/fix-checkboxselectmultiple-require-at-least-one
Changing multiple checkboxes from "must check all" to "check at least one"
2 parents dc19e85 + 9cf098a commit 53549ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

forms_builder/forms/forms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ def __init__(self, form, context, *args, **kwargs):
202202

203203
# Add identifying CSS classes to the field.
204204
css_class = field_class.__name__.lower()
205-
if field.required:
205+
# Do not add the 'required' field to the CheckboxSelectMultiple because it will
206+
# mean that all checkboxes have to be checked instead of the usual use case of
207+
# "at least one".
208+
if field.required and (field_widget != forms.CheckboxSelectMultiple):
206209
css_class += " required"
207210
if settings.USE_HTML5:
208211
# Except Django version 1.10 this is necessary for all versions from 1.8 to 1.11.

0 commit comments

Comments
 (0)