Commit 4e33ff05 by Lucian Mocanu

Automatically set the field name as value for the HTML `id` attribute on the rendered widget.

parent 5333a931
...@@ -154,7 +154,12 @@ class Field(object): ...@@ -154,7 +154,12 @@ class Field(object):
def widget_html(self): def widget_html(self):
if not self.widget: if not self.widget:
return '' return ''
return self.widget.render(self._name, self._value)
attrs = {}
if 'id' not in self.widget.attrs:
attrs['id'] = self._name
return self.widget.render(self._name, self._value, attrs=attrs)
def label_tag(self): def label_tag(self):
return '<label for="%s">%s:</label>' % (self._name, self.label) return '<label for="%s">%s:</label>' % (self._name, self.label)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment