Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2640 closed defect (fixed)

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

Reported by: torbjornthorsen@… Owned by: adrian
Component: Validators Version: master
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: UI/UX:

Description

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.

Notes:
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@… 9 years ago.
Patch for using is_required on CheckboxField

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by torbjornthorsen@…

Patch for using is_required on CheckboxField

comment:1 Changed 9 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

comment:2 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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