mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #7195 -- Fixed the validation of MultipleChoice fields so that they can
be populated from request.REQUEST. Based on a patch from Daniel Roseman. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8525 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -540,8 +540,9 @@ zero-based index.
|
||||
<li><label for="composers_id_1"><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li>
|
||||
</ul>
|
||||
|
||||
Data for a MultipleChoiceField should be a list. QueryDict and MultiValueDict
|
||||
conveniently work with this.
|
||||
Data for a MultipleChoiceField should be a list. QueryDict, MultiValueDict and
|
||||
MergeDict (when created as a merge of MultiValueDicts) conveniently work with
|
||||
this.
|
||||
>>> data = {'name': 'Yesterday', 'composers': ['J', 'P']}
|
||||
>>> f = SongForm(data)
|
||||
>>> f.errors
|
||||
@@ -556,6 +557,11 @@ conveniently work with this.
|
||||
>>> f = SongForm(data)
|
||||
>>> f.errors
|
||||
{}
|
||||
>>> from django.utils.datastructures import MergeDict
|
||||
>>> data = MergeDict(MultiValueDict(dict(name=['Yesterday'], composers=['J', 'P'])))
|
||||
>>> f = SongForm(data)
|
||||
>>> f.errors
|
||||
{}
|
||||
|
||||
The MultipleHiddenInput widget renders multiple values as hidden fields.
|
||||
>>> class SongFormHidden(Form):
|
||||
|
||||
Reference in New Issue
Block a user