diff --git a/django/newforms/forms.py b/django/newforms/forms.py index b8911dd013..8b58b94ccd 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -118,7 +118,10 @@ class Form(object): self.__errors = errors return for name, field in self.fields.items(): - value = self.data.get(name, None) + # value_from_datadict() gets the data from the dictionary. + # Each widget type knows how to retrieve its own data, because some + # widgets split data over several HTML fields. + value = field.widget.value_from_datadict(self.data, name) try: value = field.clean(value) self.clean_data[name] = value diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 1e7c839969..51bbaf0896 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -36,6 +36,13 @@ class Widget(object): attrs.update(extra_attrs) return attrs + def value_from_datadict(self, data, name): + """ + Given a dictionary of data and this widget's name, returns the value + of this widget. Returns None if it's not provided. + """ + return data.get(name, None) + def id_for_label(self, id_): """ Returns the HTML ID attribute of this Widget for use by a