From d02745f6b5a45f87d4d12b04f76f7900dddfde2a Mon Sep 17 00:00:00 2001
From: Sebastian Noack <sebastian.noack@gmail.com>
Date: Mon, 5 May 2008 17:27:43 +0200
Subject: [PATCH] Added working hidden_widget to MultiValueField (#6920).
---
django/newforms/fields.py | 4 +++-
django/newforms/forms.py | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/django/newforms/fields.py b/django/newforms/fields.py
index 08e8b84..01b364b 100644
a
|
b
|
from django.utils.translation import ugettext_lazy as _
|
21 | 21 | from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str |
22 | 22 | |
23 | 23 | from util import ErrorList, ValidationError |
24 | | from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput |
| 24 | from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput, MultiWidget |
25 | 25 | |
26 | 26 | |
27 | 27 | __all__ = ( |
… |
… |
class MultiValueField(Field):
|
671 | 671 | f.required = False |
672 | 672 | self.fields = fields |
673 | 673 | |
| 674 | self.hidden_widget = MultiWidget([f.hidden_widget for f in fields]) |
| 675 | |
674 | 676 | def clean(self, value): |
675 | 677 | """ |
676 | 678 | Validates every value in the given list. A value is validated against |
diff --git a/django/newforms/forms.py b/django/newforms/forms.py
index 2c481e4..55223eb 100644
a
|
b
|
class BoundField(StrAndUnicode):
|
306 | 306 | """ |
307 | 307 | Returns a string of HTML for representing this as an <input type="hidden">. |
308 | 308 | """ |
309 | | return self.as_widget(self.field.hidden_widget(), attrs) |
| 309 | w = self.field.hidden_widget |
| 310 | return self.as_widget(isinstance(w, type) and w() or w, attrs) |
310 | 311 | |
311 | 312 | def _data(self): |
312 | 313 | """ |