mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	bug fix: Prevent API forms from being submitted multiple times
- A problem if you're a manic clicker
This commit is contained in:
		@@ -511,6 +511,10 @@ function insertConfirmButton(options) {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
function submitFormData(fields, 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
 | 
					    // Form data to be uploaded to the server
 | 
				
			||||||
    // Only used if file / image upload is required
 | 
					    // Only used if file / image upload is required
 | 
				
			||||||
    var form_data = new FormData();
 | 
					    var form_data = new FormData();
 | 
				
			||||||
@@ -778,6 +782,9 @@ function clearFormErrors(options) {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
function handleFormErrors(errors, fields, 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
 | 
					    // Remove any existing error messages from the form
 | 
				
			||||||
    clearFormErrors(options);
 | 
					    clearFormErrors(options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user