Ticket #8993: forms_formsets.diff

File forms_formsets.diff, 1.7 KB (added by andrew.mcmurry@…, 16 years ago)
  • django/forms/formsets.py

     
    272272        forms = u' '.join([form.as_table() for form in self.forms])
    273273        return mark_safe(u'\n'.join([unicode(self.management_form), forms]))
    274274
     275    def as_table_wide(self):
     276        "Returns this formset rendered as HTML <tr>s -- excluding the <table></table>."
     277        forms = u'\n'.join(['<tr>'+form.as_row()+'</tr>'
     278                            for form in self.forms])
     279        return mark_safe(u'\n'.join([unicode(self.management_form), forms]))
     280
    275281def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
    276282                    can_delete=False, max_num=0):
    277283    """Return a FormSet for the given form class."""
  • django/forms/forms.py

     
    182182        "Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
    183183        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)
    184184
     185    def as_row(self):
     186        "Returns this form rendered as HTML <td>s -- excluding the <tr></tr>."
     187        return self._html_output(u'<td>%(errors)s%(field)s</td>', u'<td colspan="0">%s</td></tr><tr>', '</td>', u'<br />%s', False)
     188
    185189    def as_ul(self):
    186190        "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
    187191        return self._html_output(u'<li>%(errors)s%(label)s %(field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False)
Back to Top