Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms: Added BoundField.label, which calculates the label of the f…

…ield based on its name

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4118 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6d36d97cb8d0c982d7481e7d439c9848ded46a77 1 parent 126e0ec
@adrianholovaty adrianholovaty authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 django/newforms/forms.py
View
8 django/newforms/forms.py
@@ -81,7 +81,7 @@ def as_table(self):
bf = BoundField(self, field, name)
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>%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)
def as_ul(self):
@@ -95,7 +95,7 @@ def as_ul(self):
line = u'<li>'
if 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)
return u'\n'.join(output)
@@ -180,6 +180,10 @@ def as_textarea(self, attrs=None):
"Returns a string of HTML for representing this as a <textarea>."
return self.as_widget(Textarea(), attrs)
+ def _label(self):
+ return pretty_name(self._name)
+ label = property(_label)
+
def _auto_id(self):
"""
Calculates and returns the ID attribute for this BoundField, if the
Please sign in to comment.
Something went wrong with that request. Please try again.