Opened 11 years ago

Closed 9 years ago

#20116 closed Bug (fixed)

ValidationError in form wizard with formsets

Reported by: foonicorn Owned by: foonicorn
Component: contrib.formtools Version: 1.5
Severity: Normal Keywords: formset, wizard
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I encountered an issue with the form wizard when the first step is a formset and the user resends a later step after completing the wizard.

Scenario:
Complete the wizard successfully
Hit the browser back button (page usually comes from cache then)
Send the last form again

Because the wizard's storage gets reseted after completion, the wizard will start with the first step. If the first step is a formset, its ManagementForm raises a ValidationError because the data is passed but doesn't contain the expected values.

Attachments (1)

formwizard_formset_test.diff (2.7 KB ) - added by foonicorn 11 years ago.

Download all attachments as: .zip

Change History (8)

by foonicorn, 11 years ago

comment:1 by Aymeric Augustin, 11 years ago

Is this the same problem as #19189?

comment:2 by steph, 11 years ago

No, I think this is another problem, because #19189 is about re-validating things an sending a user back to a form. This ticket is about an finished wizard (done was called and response was rendered) and the user clicks the back button of the browser.

comment:3 by foonicorn, 11 years ago

Has patch: set
Owner: changed from nobody to foonicorn
Status: newassigned

I've created a patch that renders the unbound first step if a POST request is sent to a not initialized wizard (storage has no current step). This is the wizard's behavior with normal forms.

Because of this I had to update some tests which did POST requests without preceding GET.

The named wizard is not affected by the issue because the step is addressed in the URL and the data is always directed to the correct form. However in one case step_url had to be assigned to storage.current_step to make the behavior consistent.

https://github.com/foonicorn/django/commit/e95124e11ddfcfec356ade1026f6ddfa58bbbd89

comment:4 by foonicorn, 11 years ago

Updated patch with tests for correct step after each POST request in FormsetWizardTests

https://github.com/foonicorn/django/commit/d906b549065d231a8849ce0c94c7458e18bde08f

comment:5 by wim@…, 11 years ago

Triage Stage: UnreviewedAccepted

Hi. For me, this ticket is accepted as an end user should not encounter a validation error in this case.

comment:6 by Tim Graham, 10 years ago

Needs documentation: set

Requiring a GET before each POST seems to be backwards incompatible, at least for tests, so that would need to be documented.

comment:7 by Greg Chapple, 9 years ago

Resolution: fixed
Status: assignedclosed

formtools has been extracted into its own repository (​​https://github.com/django/django-formtools/). Because of this, the issue tracking for this package has been moved to GitHub issues. I'm going to close this ticket, but I've created a GitHub issue to replace it where the conversation can continue: ​​https://github.com/django/django-formtools/issues/20. Thanks!

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