﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23580	forms.fields.NullBooleanField does not honor required=True	Jon Dufresne	nobody	"I use `forms.fields.NullBooleanField` to allow a user to select Yes, No or Unknown (Unknown may also mean ""no answer""). Sometimes -- depending on the site configuration -- this field should be required, other times not. In this case, required means that either Yes or No should be selected. The field should *not* be left blank (Unknown or ""no answer""). Currently, when `required=True` is set, `forms.fields.NullBooleanField.validate()` does nothing and will simply validate all values.

I can't use `forms.fields.BooleanField` because when `required=True` is set Yes *must* be selected for the field to validate.

This topic has come up in the past: <https://groups.google.com/d/msg/django-developers/eN7FvAvTsew/kLQ4FdE3fWAJ>

I propose `forms.fields.NullBooleanField` be altered to handle required. That is change validate to:

{{{
    def validate(self, value):
        if value is None and self.required:
            raise ValidationError(....
}}}

I'll happily create a pull request to achieve this. One concern will be backwards compatibility. But seeing as how `required=True` had no effect on the field originally, I see no reason anyone would set it and expect something useful other than what has been suggested above."	Uncategorized	closed	Forms	dev	Normal	invalid		jon.dufresne@…	Unreviewed	1	0	0	0	0	0
