root/misc/forms.py.patch

Revision 58, 2.1 kB (checked in by razor, 22 months ago)

Added patch for forms.py

  • forms.py

     
    162162                    help_text = help_text_html % force_unicode(field.help_text) 
    163163                else: 
    164164                    help_text = u'' 
    165                 output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text}) 
     165                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}) 
    166166        if top_errors: 
    167167            output.insert(0, error_row % force_unicode(top_errors)) 
    168168        if hidden_fields: # Insert any hidden fields in the last row. 
     
    180180 
    181181    def as_table(self): 
    182182        "Returns this form rendered as HTML <tr>s -- excluding the <table></table>." 
    183         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) 
     183        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) 
    184184 
    185185    def as_ul(self): 
    186186        "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." 
    187         return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False) 
     187        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) 
    188188 
    189189    def as_p(self): 
    190190        "Returns this form rendered as HTML <p>s." 
    191         return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True) 
     191        return self._html_output(u'<p class="%(classes)s">%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True) 
    192192 
    193193    def non_field_errors(self): 
    194194        """ 
Note: See TracBrowser for help on using the browser.