Ticket #6043: newforms_forms.py.2.diff
File newforms_forms.py.2.diff, 2.0 KB (added by , 17 years ago) |
---|
-
newforms/forms.py
141 141 help_text = help_text_html % force_unicode(field.help_text) 142 142 else: 143 143 help_text = u'' 144 output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text })144 output.append(normal_row % {'errors': force_unicode(bf_errors), 'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text, 'required': field.required and '<span class="required"> * </span>' or ''}) 145 145 if top_errors: 146 146 output.insert(0, error_row % top_errors) 147 147 if hidden_fields: # Insert any hidden fields in the last row. … … 156 156 157 157 def as_table(self): 158 158 "Returns this form rendered as HTML <tr>s -- excluding the <table></table>." 159 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)159 return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s%(required)s</td></tr>', u'<tr><td colspan="2">%s</td></tr>', '</td></tr>', u'<br />%s', False) 160 160 161 161 def as_ul(self): 162 162 "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." 163 return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s </li>', u'<li>%s</li>', '</li>', u' %s', False)163 return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s%(required)s</li>', u'<li>%s</li>', '</li>', u' %s', False) 164 164 165 165 def as_p(self): 166 166 "Returns this form rendered as HTML <p>s." 167 return self._html_output(u'<p>%(label)s %(field)s%(help_text)s </p>', u'%s', '</p>', u' %s', True)167 return self._html_output(u'<p>%(label)s %(field)s%(help_text)s%(required)s</p>', u'%s', '</p>', u' %s', True) 168 168 169 169 def non_field_errors(self): 170 170 """