﻿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
24453	Initial values for ManyToMany form fields can't be hidden	girzel	nobody	"Initial values can be provided for the ManyToMany field of a ModelForm, to be used in a ModelFormSet, but if the widget is switched to the HiddenInput class, the (as far as I can tell correct) initial value creates a validation error:

(Hidden field <field_name>) Enter a list of values.

Take this model:

{{{
class Work(models.Model):
  authors = models.ManyToManyField(Author)

initial = dict(authors=[some_author_instance])

formset = WorkFormSet(queryset=Work.objects.none(), initial=[initial])
}}}

This is supposing one extra form in the formset. If the ""authors"" field remains unhidden, the initial value works as expected. If we switch the ""authors"" widget to a forms.HiddenInput, however, I get the above validation error.

I don't think simply hiding the input should affect how the initial values are treated. FWIW, here's an example what the hidden input looks like in the HTML:

`<input id=""id_form-1-authors"" name=""form-1-authors"" type=""hidden"" value=""[37L]"" />`

So presumably ""[37L]"" isn't getting read as a list, somewhere...

"	Bug	closed	Forms	1.7	Normal	invalid			Unreviewed	0	0	0	0	0	0
