1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +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:
Adrian Holovaty
2007-01-13 04:51:57 +00:00
parent 663ef14f02
commit a0137c41f3
2 changed files with 21 additions and 2 deletions

View File

@@ -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'