diff options
Diffstat (limited to 'django/newforms/widgets.py')
| -rw-r--r-- | django/newforms/widgets.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 996e353775..df8bb19c4f 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -3,8 +3,8 @@ HTML Widget classes """ __all__ = ( - 'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'FileInput', - 'Textarea', 'CheckboxInput', + 'Widget', 'TextInput', 'PasswordInput', 'HiddenInput', 'MultipleHiddenInput', + 'FileInput', 'Textarea', 'CheckboxInput', 'Select', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple', ) @@ -87,6 +87,16 @@ class HiddenInput(Input): input_type = 'hidden' is_hidden = True +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): + 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]) + class FileInput(Input): input_type = 'file' |
