diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-25 00:32:32 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-25 00:32:32 +0000 |
| commit | 6d6fb392b4732fa4ff77e918c06ffcd92e753d9b (patch) | |
| tree | b8862547493e33774dbff4e1e120644419320e76 /tests/regressiontests/forms/forms.py | |
| parent | d6e5632969b95a3f99f95ef7d0f94178a923a5e9 (diff) | |
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
Diffstat (limited to 'tests/regressiontests/forms/forms.py')
| -rw-r--r-- | tests/regressiontests/forms/forms.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/regressiontests/forms/forms.py b/tests/regressiontests/forms/forms.py index d834bdaccc..76132b273f 100644 --- a/tests/regressiontests/forms/forms.py +++ b/tests/regressiontests/forms/forms.py @@ -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): |
