mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #3289 -- newforms: Added value_from_datadict method to MultipleHiddenInput
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4311 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1950,11 +1950,20 @@ conveniently work with this.
|
||||
>>> f.errors
|
||||
{}
|
||||
>>> from django.utils.datastructures import MultiValueDict
|
||||
>>> data = MultiValueDict(dict(name='Yesterday', composers=['J', 'P']))
|
||||
>>> data = MultiValueDict(dict(name=['Yesterday'], composers=['J', 'P']))
|
||||
>>> f = SongForm(data)
|
||||
>>> f.errors
|
||||
{}
|
||||
|
||||
The MultipleHiddenInput widget renders multiple values as hidden fields.
|
||||
>>> class SongFormHidden(Form):
|
||||
... name = CharField()
|
||||
... composers = MultipleChoiceField(choices=[('J', 'John Lennon'), ('P', 'Paul McCartney')], widget=MultipleHiddenInput)
|
||||
>>> f = SongFormHidden(MultiValueDict(dict(name=['Yesterday'], composers=['J', 'P'])), auto_id=False)
|
||||
>>> print f.as_ul()
|
||||
<li>Name: <input type="text" name="name" value="Yesterday" /><input type="hidden" name="composers" value="J" />
|
||||
<input type="hidden" name="composers" value="P" /></li>
|
||||
|
||||
When using CheckboxSelectMultiple, the framework expects a list of input and
|
||||
returns a list of input.
|
||||
>>> f = SongForm({'name': 'Yesterday'}, auto_id=False)
|
||||
|
||||
Reference in New Issue
Block a user