diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 4fffde3b7ee..1750a094895 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -202,9 +202,10 @@ class BoundField(object): field's HTML-escaped verbose_name. """ contents = contents or escape(self.verbose_name) - id_ = self._field.widget.attrs.get('id') or self.auto_id + widget = self._field.widget + id_ = widget.attrs.get('id') or self.auto_id if id_: - contents = '' % (id_, contents) + contents = '' % (widget.id_for_label(id_), contents) return contents def _auto_id(self): diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 318c76e55d0..b4eac248fc0 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -35,6 +35,19 @@ class Widget(object): attrs.update(extra_attrs) return attrs + def id_for_label(self, id_): + """ + Returns the HTML ID attribute of this Widget for use by a