verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
93 stars 68 forks source link

Multi-page form submission failing when form contains File Upload field #1910

Open simonleadbetter opened 3 weeks ago

simonleadbetter commented 3 weeks ago

Describe the bug

We have noticed an issue on a multi-page form, where the association to a file uploaded via the File Upload field goes missing when navigating back/forward in the form. This means when the user is on the final page, they cannot submit the form due to an error displayed on the mandatory File Upload field.

For the form I tested this on, the File Upload field is in a group; however, I tested this with another File Upload field and it suffered the same issue.

When I hard refreshed the page, the File Upload field displayed the association beneath the field. However, as soon as I navigated to another page the association was lost.

I think I have isolated the issue and it is caused by the AJAX form submission method. I switched to Page Reload and the File Upload field maintain its association and I was able to successfully submit the form.

Steps to reproduce

  1. Add a File Upload filed to a multi-page form
  2. Ensure AJAX is selected as the Submission Method
  3. Navigate to another page and then revisit the page with the File Upload field

Form settings

Craft CMS version

4.9.1

Plugin version

2.1.18

Multi-site?

Yes

Additional context

This issue occurs in all environments

engram-design commented 3 weeks ago

There's a couple of open issues for this https://github.com/verbb/formie/issues/1856 https://github.com/verbb/formie/issues/1448 and it's a known issue with Ajax-based forms. There's only two real options:

I'm not a massive fan of the former, and the latter is pretty involved.

The reason we clear the file upload field is that otherwise, every time a page is submitted, the entire form's content will be sent. There's complicated reasons for this rather than just submitting the current page (mostly for conditions).

I suppose another alternative is to have an internal register of field that have been "uploaded" and to ignore them. But that'll be tricky because if a user goes back and changes the uploaded files, we actually do want those uploaded again.