mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Automatically set the field name as value for the HTML id
attribute on the rendered widget.
This commit is contained in:
parent
5333a93126
commit
4e33ff05d9
|
@ -154,7 +154,12 @@ class Field(object):
|
|||
def widget_html(self):
|
||||
if not self.widget:
|
||||
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):
|
||||
return '<label for="%s">%s:</label>' % (self._name, self.label)
|
||||
|
|
Loading…
Reference in New Issue
Block a user