diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-01-13 04:51:57 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-01-13 04:51:57 +0000 |
| commit | a0137c41f3b9b95d48f42ddd0fb48703a88a8c94 (patch) | |
| tree | 25238a9061953e4359e730f8d6ff3e3ec2604b9e /django/newforms | |
| parent | 663ef14f02e459d116bcf0e562ba8526c7d49fcf (diff) | |
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
Diffstat (limited to 'django/newforms')
| -rw-r--r-- | django/newforms/widgets.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 4e4fc0c80b..4bbd02dc63 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -92,11 +92,21 @@ class MultipleHiddenInput(HiddenInput): A widget that handles <input type="hidden"> for fields that have a list of values. """ - def render(self, name, value, attrs=None): + def __init__(self, attrs=None, choices=()): + # choices can be any iterable + self.attrs = attrs or {} + self.choices = choices + + def render(self, name, value, attrs=None, choices=()): if value is None: value = [] final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) return u'\n'.join([(u'<input%s />' % flatatt(dict(value=smart_unicode(v), **final_attrs))) for v in value]) + def value_from_datadict(self, data, name): + if isinstance(data, MultiValueDict): + return data.getlist(name) + return data.get(name, None) + class FileInput(Input): input_type = 'file' |
