newforms: Removed Widget.requires_data_list parameter, which was made redundant by Widget.value_from_datadict()
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f6fd5827aa
commit
3d9b12b2d8
|
@ -234,9 +234,7 @@ class BoundField(StrAndUnicode):
|
|||
|
||||
def _data(self):
|
||||
"Returns the data for this BoundField, or None if it wasn't given."
|
||||
if self.field.widget.requires_data_list and isinstance(self.form.data, MultiValueDict):
|
||||
return self.form.data.getlist(self.html_name)
|
||||
return self.form.data.get(self.html_name, None)
|
||||
return self.field.widget.value_from_datadict(self.form.data, self.html_name)
|
||||
data = property(_data)
|
||||
|
||||
def label_tag(self, contents=None):
|
||||
|
|
|
@ -23,13 +23,18 @@ except NameError:
|
|||
flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()])
|
||||
|
||||
class Widget(object):
|
||||
requires_data_list = False # Determines whether render()'s 'value' argument should be a list.
|
||||
is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
|
||||
|
||||
def __init__(self, attrs=None):
|
||||
self.attrs = attrs or {}
|
||||
|
||||
def render(self, name, value):
|
||||
def render(self, name, value, attrs=None):
|
||||
"""
|
||||
Returns this Widget rendered as HTML, as a Unicode string.
|
||||
|
||||
The 'value' given is not guaranteed to be valid input, so subclass
|
||||
implementations should program defensively.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def build_attrs(self, extra_attrs=None, **kwargs):
|
||||
|
@ -130,7 +135,6 @@ class Select(Widget):
|
|||
return u'\n'.join(output)
|
||||
|
||||
class SelectMultiple(Widget):
|
||||
requires_data_list = True
|
||||
def __init__(self, attrs=None, choices=()):
|
||||
# choices can be any iterable
|
||||
self.attrs = attrs or {}
|
||||
|
|
Loading…
Reference in New Issue