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.
- User receives a server error that happens after the form has processed the submission but before the response is rendered.
- User sees an error page from the server even though the form submission was successful and marked as completed.
- User clicks the back button in the browser and sees the last step of the form filled out.
- User submits the form and sees a successful page.
- 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
- Make a multi step form that requires fields on step 1 and step 2.
- Add a pdb statement to the serve method after the final submission is created but before a response is rendered.
- Fill out the form and go to the debugger and put in
raise ValueError and then continue.
- You should see an error page in the browser. Hit the back button.
- You should be on the last step of the form with the fields filled out. Hit submit.
- Go to the debugger and enter
c to continue.
- You should get a successful message.
- 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.
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.
Steps to reproduce
raise ValueErrorand then continue.cto continue.The issue
The
update_datamethod ofStepsonly 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.