Opened 15 years ago

Closed 15 years ago

#12551 closed (duplicate)

html_class_attr is not being cleared in loop within forms._html_output

Reported by: Skidd Owned by: nobody
Component: Forms Version: 1.2-alpha
Severity: Keywords: error_css_class form field
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The _html_output() method within django.forms.BaseForm
has a for loop that creates a TR for each field.
The html_class_attr field is not being cleared while iterating through the loop.
As soon as one field has this value set, all following fields get it too.

I found this while using a ModelForm that was forcing all fields to required.

Fix:

    if css_classes:
        html_class_attr = ' class="%s"' % css_classes
    else: 
        html_class_attr = ''

or

    for name, field in self.fields.items():
        html_class_attr = ''

Thanks

Change History (1)

comment:1 by Jannis Leidel, 15 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #12466

Note: See TracTickets for help on using tickets.
Back to Top