Skip to content

Form with multiple steps can create a final submission without all the required fields from previous steps. #12

Description

@mjfinney

In certain situations the form can create a duplicate entry that only includes the data in the last step.

User Case

This is an odd case that can happen when the user receives a server error in just the right place between form completion and returning a response.

  1. User receives a server error that happens after the form has processed the submission but before the response is rendered.
  2. User sees an error page from the server even though the form submission was successful and marked as completed.
  3. User clicks the back button in the browser and sees the last step of the form filled out.
  4. User submits the form and sees a successful page.
  5. Wagtail shows an entry for the first submission with all the data, followed by an entry with only the data from the last step.

Steps to reproduce

  1. Make a multi step form that requires fields on step 1 and step 2.
  2. Add a pdb statement to the serve method after the final submission is created but before a response is rendered.
  3. Fill out the form and go to the debugger and put in raise ValueError and then continue.
  4. You should see an error page in the browser. Hit the back button.
  5. You should be on the last step of the form with the fields filled out. Hit submit.
  6. Go to the debugger and enter c to continue.
  7. You should get a successful message.
  8. Check the form submissions. You should see two, one with data from both steps and one with data from only the last step.

The issue

The update_data method of Steps only checks to see if the current request is the last step of the form and does not check to make sure previous steps have been filled out.

https://github.com/coderedcorp/wagtail-flexible-forms/blob/main/wagtail_flexible_forms/models.py#L292

It should make sure it is on the last step and also make sure that all required information is in the submission. This would at least make sure the user fills the form out with all the required information before getting to the last step. However, this does not tell the user that the form was previously submitted successfully. There might be a way to check if the submission was already submitted successfully on the second submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions