From 6d6fb392b4732fa4ff77e918c06ffcd92e753d9b Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 25 Aug 2008 00:32:32 +0000 Subject: 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 --- tests/regressiontests/forms/forms.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/regressiontests/forms') 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.
  • -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): -- cgit v1.3