Code

Opened 7 years ago

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

Download all attachments as: .zip

Change History (4)

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

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by jkocherhans

  • Owner changed from nobody to jkocherhans
  • Status changed from new to assigned

comment:3 Changed 7 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.