diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-11-27 04:23:20 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-11-27 04:23:20 +0000 |
| commit | 6d36d97cb8d0c982d7481e7d439c9848ded46a77 (patch) | |
| tree | c02cb481e700b87d0f61b1ae4b849a8aecb37ee2 | |
| parent | 126e0ec0c3096ae5c631b00b29ff9e9f01ca15c2 (diff) | |
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
| -rw-r--r-- | django/newforms/forms.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py index bf05e38fc2..a07df84e54 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -81,7 +81,7 @@ class Form(object): 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 @@ class Form(object): 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 @@ class BoundField(object): "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 |
