Ticket #9854: django-form-patch.diff

File django-form-patch.diff, 1.9 KB (added by h3, 14 years ago)

Allow FORM_HELP_TEXT_HTML to be specified site-wite in settings.py

  • forms.py

     
    1717
    1818NON_FIELD_ERRORS = '__all__'
    1919
     20try:
     21    from django.conf import settings
     22    FORM_HELP_TEXT_HTML = settings.FORM_HELP_TEXT_HTML
     23except ImportError:
     24    FORM_HELP_TEXT_HTML = u' %s'
     25
    2026def pretty_name(name):
    2127    "Converts 'first_name' to 'First name'"
    2228    name = name[0].upper() + name[1:]
     
    6369            new_class.media = media_property(new_class)
    6470        return new_class
    6571
     72
    6673class BaseForm(StrAndUnicode):
    6774    # This is the main implementation of all the Form logic. Note that this
    6875    # class is different than Form. See the comments by the Form class for more
     
    187194
    188195    def as_table(self):
    189196        "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
    190         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)
     197        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>', FORM_HELP_TEXT_HTML, False)
    191198
    192199    def as_ul(self):
    193200        "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
    194         return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
     201        return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', FORM_HELP_TEXT_HTML, False)
    195202
    196203    def as_p(self):
    197204        "Returns this form rendered as HTML <p>s."
    198         return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', u' %s', True)
     205        return self._html_output(u'<p>%(label)s %(field)s%(help_text)s</p>', u'%s', '</p>', FORM_HELP_TEXT_HTML, True)
    199206
    200207    def non_field_errors(self):
    201208        """
Back to Top