Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#2640 closed defect (fixed)

[patch] django.forms.CheckboxField should be able to use is_required

Reported by: torbjornthorsen@… Owned by: Adrian Holovaty
Component: Validators Version: dev
Severity: normal Keywords: Manipulator Validator Checkbox
Cc: torbjornthorsen@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


There is currently no way of using the is_required attribut for a CheckboxField.

Use case:
In some forms it is usual practice to but confirmation checkboxes that users must check (aknowleding EULA and such) before a form is considered complete. In my mind ValidationError should be raised for FormWrapper when this is not the case.

The current version of CheckboxField takes a validator_list, which may be useful, but these are only called when the checkbox is visible in request.POST, ie. when the user has checked the checkbox.
What is needed for the use case is a boolean validator to run even if checkbox is not visible in request.POST.

html2python: I did some testing, and html2python is only called if the checkbox has been checked, and as the checkbox widget is a boolean, I choose to just return true, as a situation where one would return false will not arise.

Attachments (1)

checkboxfield.patch (1.1 KB ) - added by torbjornthorsen@… 18 years ago.
Patch for using is_required on CheckboxField

Download all attachments as: .zip

Change History (3)

by torbjornthorsen@…, 18 years ago

Attachment: checkboxfield.patch added

Patch for using is_required on CheckboxField

comment:1 by anonymous, 18 years ago

Summary: django.forms.CheckboxField should be able to use is_required[patch] django.forms.CheckboxField should be able to use is_required

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [3780]) Fixed #2640 -- Allow is_required for CheckboxField classes (defaults to False,
which was the previous behaviour). Thanks, torbjornthorsen@….

Note: See TracTickets for help on using tickets.
Back to Top