﻿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
5033	Dynamic initial values for MultipleChoiceFields in newforms	matt@…	nobody	"The newforms documentation specifies that forms can be pre-populated with dynamic values using an 'initial' dictionary. From the docs:


{{{
>>> class CommentForm(forms.Form):
...     name = forms.CharField()
...     url = forms.URLField()
...     comment = forms.CharField()
>>> f = CommentForm(initial={'name': 'your username'}, auto_id=False)
>>> print f
<tr><th>Name:</th><td><input type=""text"" name=""name"" value=""your username"" /></td></tr>
...
}}}

This works fine if the form element is a CharField as in the example above. However, if the form element is a MultipleChoiceField, the initial value is required to be the {{{id}}} of the object you're trying to select - not the string representation as required for CharField, TextField et al.

It's fairly obvious when you think about it, but it would have saved me some time if the docs mentioned it.

"		closed	Documentation	dev		wontfix	dynamic values, MultipleChoiceField, newforms	matt@…	Unreviewed	0	0	0	0	0	0
