Opened 9 years ago

Closed 9 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: UI/UX:

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@…> 9 years ago.

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Petr Marhoun <petr.marhoun@…>

Attachment: formsets-validation.diff added

comment:1 Changed 9 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 9 years ago by jkocherhans

Owner: changed from nobody to jkocherhans
Status: newassigned

comment:3 Changed 9 years ago by jkocherhans

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