[patch] django.forms.CheckboxField should be able to use is_required
|Reported by:||torbjornthorsen@…||Owned by:||adrian|
|Severity:||normal||Keywords:||Manipulator Validator Checkbox|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
There is currently no way of using the is_required attribut for a CheckboxField.
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.
Change History (3)
Changed 8 years ago by torbjornthorsen@…
comment:1 Changed 8 years ago by anonymous
- Summary changed from django.forms.CheckboxField should be able to use is_required to [patch] django.forms.CheckboxField should be able to use is_required