diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-01-09 05:12:25 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-01-09 05:12:25 +0000 |
| commit | fb60a6ff0acc84417ced061e83bb170fff351b59 (patch) | |
| tree | 3b7bf5cf6373a50430276bc3d479c32054e6c0ea /django/newforms/widgets.py | |
| parent | 2e148d70647bfab640ab395fc98ba9492d061dad (diff) | |
Fixed #3193 -- newforms: Modified as_hidden() to handle MultipleChoiceField correctly. Thanks for the report, Honza Kral
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4298 bcc190cf-cafb-0310-a4f2-bffc1f526a37
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' |
