newforms: Added BoundField.label, which calculates the label of the field based on its name
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4118 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
126e0ec0c3
commit
6d36d97cb8
|
@ -81,7 +81,7 @@ class Form(object):
|
||||||
bf = BoundField(self, field, name)
|
bf = BoundField(self, field, name)
|
||||||
if bf.errors:
|
if bf.errors:
|
||||||
output.append(u'<tr><td colspan="2"><ul>%s</ul></td></tr>' % u'\n'.join([u'<li>%s</li>' % e for e in bf.errors]))
|
output.append(u'<tr><td colspan="2"><ul>%s</ul></td></tr>' % u'\n'.join([u'<li>%s</li>' % e for e in bf.errors]))
|
||||||
output.append(u'<tr><td>%s:</td><td>%s</td></tr>' % (pretty_name(name), bf))
|
output.append(u'<tr><td>%s:</td><td>%s</td></tr>' % (bf.label, bf))
|
||||||
return u'\n'.join(output)
|
return u'\n'.join(output)
|
||||||
|
|
||||||
def as_ul(self):
|
def as_ul(self):
|
||||||
|
@ -95,7 +95,7 @@ class Form(object):
|
||||||
line = u'<li>'
|
line = u'<li>'
|
||||||
if bf.errors:
|
if bf.errors:
|
||||||
line += u'<ul>%s</ul>' % u'\n'.join([u'<li>%s</li>' % e for e in bf.errors])
|
line += u'<ul>%s</ul>' % u'\n'.join([u'<li>%s</li>' % e for e in bf.errors])
|
||||||
line += u'%s: %s</li>' % (pretty_name(name), bf)
|
line += u'%s: %s</li>' % (bf.label, bf)
|
||||||
output.append(line)
|
output.append(line)
|
||||||
return u'\n'.join(output)
|
return u'\n'.join(output)
|
||||||
|
|
||||||
|
@ -180,6 +180,10 @@ class BoundField(object):
|
||||||
"Returns a string of HTML for representing this as a <textarea>."
|
"Returns a string of HTML for representing this as a <textarea>."
|
||||||
return self.as_widget(Textarea(), attrs)
|
return self.as_widget(Textarea(), attrs)
|
||||||
|
|
||||||
|
def _label(self):
|
||||||
|
return pretty_name(self._name)
|
||||||
|
label = property(_label)
|
||||||
|
|
||||||
def _auto_id(self):
|
def _auto_id(self):
|
||||||
"""
|
"""
|
||||||
Calculates and returns the ID attribute for this BoundField, if the
|
Calculates and returns the ID attribute for this BoundField, if the
|
||||||
|
|
Loading…
Reference in New Issue