﻿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
7208	Newforms SelectMultiple widget doesn't work with required=False and ChoiceField	jordan+django@…	nobody	"!ChoiceFields using the !SelectMultiple widget fail validation when optional and the browser doesn't submit a value for it.

Firefox won't submit a value for <select> form fields. Without a value, !SelectMultiple sets the value to []. 

The clean() function in !ChoiceField checks to see if the value is None or an empty string via EMPTY_VALUES, but not [], so it tries to lookup [] in the list of acceptable choices and fails with an invalid_choice message. 

{{{
#!python
from django import newforms as forms
from django.http import QueryDict

class PostForm(forms.Form):
	text = forms.CharField()
	broken = forms.ChoiceField(widget=forms.SelectMultiple, required=False)

# Firefox won't submit a <select> form field that has no option selected
postdata = QueryDict('&text=super')
form = PostForm(postdata)
form.is_valid()
form.errors
}}}

This will output:
{{{
>>> form.is_valid()
False
>>> form.errors
{'broken': [u'Select a valid choice. That choice is not one of the available choices.']}
}}}"		closed	Forms	dev		duplicate			Unreviewed	0	0	0	0	0	0
