From 60e8a17f0702e2945481bdbdc1de8ccb8fa255fd Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 9 Jul 2021 01:06:38 +1000 Subject: [PATCH] bug fix: Prevent API forms from being submitted multiple times - A problem if you're a manic clicker --- InvenTree/templates/js/forms.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index 4af3a6f45e..1de62dd3f5 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -511,6 +511,10 @@ function insertConfirmButton(options) { */ function submitFormData(fields, options) { + // Immediately disable the "submit" button, + // to prevent the form being submitted multiple times! + $(options.modal).find('#modal-form-submit').prop('disabled', true); + // Form data to be uploaded to the server // Only used if file / image upload is required var form_data = new FormData(); @@ -778,6 +782,9 @@ function clearFormErrors(options) { */ function handleFormErrors(errors, fields, options) { + // Reset the status of the "submit" button + $(options.modal).find('#modal-form-submit').prop('disabled', false); + // Remove any existing error messages from the form clearFormErrors(options);