﻿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
5145	MultiWidget / MultiValueField does not interpret initial data	daofma@…	Manuel Saelices	"Below I've used SplitDateTime as an example, but it applies to other MultiWidget / MultiValueField as well, as I came across the issue using a custom MultiWidget / MultiValueField. I'm not sure in which the problem lies. Generally, the MultiValueField accepts values from the ""data="" argument to the form constructor, and these appear when the MultiWidget is rendered just fine. However, when a dictionary is passed through the ""initial="" argument, it does not appear. An example follows:


{{{
>>> from django.newforms import *
>>> class TestForm(Form):
...     the_datetime_field = SplitDateTimeField(widget=SplitDateTimeWidget)
... 
>>> test_data = {'the_datetime_field_0':'12/24/07', 'the_datetime_field_1':'15:00'}
>>> unbound_form_no_initial = TestForm()
>>> unbound_form_no_initial.as_p()
u'<p><label for=""id_the_datetime_field_0"">The datetime field:</label> <input type=""text"" name=""the_datetime_field_0"" id=""id_the_datetime_field_0"" /><input type=""text"" name=""the_datetime_field_1"" id=""id_the_datetime_field_1"" /></p>'
>>> bound_form = TestForm(data=test_data)
>>> bound_form.as_p()
u'<p><label for=""id_the_datetime_field_0"">The datetime field:</label> <input type=""text"" name=""the_datetime_field_0"" value=""12/24/07"" id=""id_the_datetime_field_0"" /><input type=""text"" name=""the_datetime_field_1"" value=""15:00"" id=""id_the_datetime_field_1"" /></p>'
>>> unbound_form_with_initial = TestForm(initial=test_data)
>>> unbound_form_with_initial.as_p()
u'<p><label for=""id_the_datetime_field_0"">The datetime field:</label> <input type=""text"" name=""the_datetime_field_0"" id=""id_the_datetime_field_0"" /><input type=""text"" name=""the_datetime_field_1"" id=""id_the_datetime_field_1"" /></p>'

}}}

As you can see, only the bound form shows the values. The first unbound form is of course not supposed to show any initial values. However, the second unbound form is passed initial values that it is supposed to show, but it does not."		closed	Forms	dev		invalid	newforms, MultiWidget, MultiValueField, initial	lurker86@…	Unreviewed	0	0	0	0	0	0
