root/misc/forms.py.patch @ 58

Revision 58, 2.1 kB (checked in by razor, 2 years ago)

Added patch for forms.py

RevLine 
[58]1Index: forms.py
2===================================================================
3--- forms.py    (revision 805)
4+++ forms.py    (working copy)
5@@ -162,7 +162,7 @@
6                     help_text = help_text_html % force_unicode(field.help_text)
7                 else:
8                     help_text = u''
9-                output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text})
10+                output.append(normal_row % {'classes': "%s %s %s" % (type(field).__name__, type(field.widget).__name__, field.required and "Required" or "Optional"),  'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text})
11         if top_errors:
12             output.insert(0, error_row % force_unicode(top_errors))
13         if hidden_fields: # Insert any hidden fields in the last row.
14@@ -180,15 +180,15 @@
15 
16     def as_table(self):
17         "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
18-        return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
19+        return self._html_output(u'<tr class="%(classes)s"><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False)
20 
21     def as_ul(self):
22         "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
23-        return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
24+        return self._html_output(u'<li class="%(classes)s">%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
25 
26     def as_p(self):
27         "Returns this form rendered as HTML <p>s."
28-        return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True)
29+        return self._html_output(u'<p class="%(classes)s">%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True)
30 
31     def non_field_errors(self):
32         """
Note: See TracBrowser for help on using the browser.