Problem/Motivation
Currently if a user tries to submit while a file is uploading they see a prompt "File upload in progress. Uploaded file may be lost. Do you want to continue?". It does not always make sense to allow a user to submit a form even though a file upload is in progress.
Steps to reproduce
- Create a webform with a file upload field.
- Navigate to the form
- Start uploading a large file. If you're testing this locally you may need to throttle the upload speed to delay the upload enough to see the prompt.
- Attempt to submit while the file is still uploading
- You should see the prompt. Confirm that you want to submit anyway.
- You will either see an error due to the missing file or see a successful form submission but notice the file is missing if you navigate to the submission
Proposed resolution
Provide an option to change this behaviour so that instead of allowing the user to submit the form mid file upload they see an alert and are unable to submit.
Remaining tasks
I will attach a patch shortly.
User interface changes
There will be a new option at /admin/structure/webform/config/elements.
Data model changes
There will be a new option in the webform.settings default config file and schema.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | After_patch.png | 424.58 KB | bebalachandra |
| #4 | 3385380-4.patch | 880 bytes | jrockowitz |
| #3 | 3385380-provide-option-disallow-submitting-file-uploading.patch | 5.35 KB | dylan donkersgoed |
Issue fork webform-3385380
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dylan donkersgoed commentedPatch attached.
Comment #4
jrockowitz commentedRight now, I am not adding any new features to the Webform module.
People can use the above patch AS-IS.
I would be open to committing an API change that allows people to override the blockSubmit function. See attached.
Comment #5
bebalachandra commentedAs @jrockowitz mentioned there is no feature implementation for now, I have skipped MR!356 from testing (however MR failed test cases).
Tested patch #4. followed all the steps which are given in "Steps to reproduce".
After overriding blockSubmit function the behaviour is same as before while uploading file and submitting. If and only we want blockSubmit function to be overridden then we can use patch #4. else we can use the module AS-IS.
Attached screenshot for reference.
Comment #6
jrockowitz commentedI want to commit #4's patch AS-IS.
Someone can create a recipe for changing the upload behavior.
Comment #10
jrockowitz commentedI committed #4
Comment #11
jrockowitz commentedComment #13
willempje2 commentedNot sure if i need to create a new issue for this but my guess would be that "blockSubmit($form)" on line 53 should be changed as well.
https://git.drupalcode.org/project/webform/-/blame/6.2.x/js/webform.elem...