Ticket #4024: forms.py.diff
File forms.py.diff, 2.5 KB (added by , 18 years ago) |
---|
-
forms.py
120 120 top_errors.extend(['(Hidden field %s) %s' % (name, e) for e in bf_errors]) 121 121 hidden_fields.append(unicode(bf)) 122 122 else: 123 css_classes = [] 123 124 if errors_on_separate_row and bf_errors: 124 125 output.append(error_row % bf_errors) 125 126 label = bf.label and bf.label_tag(escape(bf.label + ':')) or '' … … 127 128 help_text = help_text_html % field.help_text 128 129 else: 129 130 help_text = u'' 130 output.append(normal_row % {'errors': bf_errors, 'label': label, 'field': unicode(bf), 'help_text': help_text}) 131 if field.required: 132 css_classes.append('required') 133 classes = u'class="%s"' % u' '.join(css_classes) 134 output.append(normal_row % {'classes': classes, 'errors': bf_errors, 'label': label, 'field': unicode(bf), 'help_text': help_text}) 131 135 if top_errors: 132 136 output.insert(0, error_row % top_errors) 133 137 if hidden_fields: # Insert any hidden fields in the last row. … … 142 146 143 147 def as_table(self): 144 148 "Returns this form rendered as HTML <tr>s -- excluding the <table></table>." 145 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)149 return self._html_output(u'<tr %(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) 146 150 147 151 def as_ul(self): 148 152 "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." 149 return self._html_output(u'<li >%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)153 return self._html_output(u'<li %(classes)s>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False) 150 154 151 155 def as_p(self): 152 156 "Returns this form rendered as HTML <p>s." 153 return self._html_output(u'<p >%(label)s %(field)s%(help_text)s</p>', u'<p>%s</p>', '</p>', u' %s', True)157 return self._html_output(u'<p %(classes)s>%(label)s %(field)s%(help_text)s</p>', u'<p>%s</p>', '</p>', u' %s', True) 154 158 155 159 def non_field_errors(self): 156 160 """