Opened 17 years ago

Closed 17 years ago

#5388 closed (fixed)

[newforms-admin] - validation is broken for sites with more than one inline formsets

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: jkocherhans
Component: Forms Version: newforms-admin
Severity: Keywords: newforms, admin, inlines
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Validation of inline formsets is done with this code:

def all_valid(formsets):
    """Returns true if every formset in formsets is valid."""
    valid = True
    for formset in formsets:
        if not formset.is_valid():
            return False

But method formset.is_valid has side-effect - it calls formset.clean_all and method clean_all resets all unused inline formset. But if first formset is invalid, forms in the second formset aren't reset.

This code works (attached patch changes it):

def all_valid(formsets):
    """Returns true if every formset in formsets is valid."""
    valid = True
    for formset in formsets:
        if not formset.is_valid():
            valid = False
    return valid

Attachments (1)

formsets-validation.diff (448 bytes ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.

Download all attachments as: .zip

Change History (4)

by Petr Marhoun <petr.marhoun@…>, 17 years ago

Attachment: formsets-validation.diff added

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by jkocherhans, 17 years ago

Owner: changed from nobody to jkocherhans
Status: newassigned

comment:3 by jkocherhans, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [6104]) newforms-admin: Fixed #5388. Validation broken for models with > 1 inline formset.

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