diff --git a/CHANGES.md b/CHANGES.md index dcd6bc111..ac376324f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ CHANGELOG - Due to new crispy forms, there is new login form - Use HTML `button` tag for create/update forms +- Prevent multiple submissions of create/update form 8.9.2 (2024-07-15) diff --git a/mapentity/forms.py b/mapentity/forms.py index df242126e..977da180c 100644 --- a/mapentity/forms.py +++ b/mapentity/forms.py @@ -229,7 +229,7 @@ def _init_layout(self): # Main form layout self.helper.help_text_inline = True - self.helper.form_class = 'form-horizontal' + self.helper.form_class = 'form-horizontal mapentity-form' self.helper.form_style = "default" self.helper.label_class = 'col-md-3' self.helper.field_class = 'controls col-md-9' diff --git a/mapentity/static/mapentity/mapentity.forms.js b/mapentity/static/mapentity/mapentity.forms.js index 36241e22b..c5b93d89f 100644 --- a/mapentity/static/mapentity/mapentity.forms.js +++ b/mapentity/static/mapentity/mapentity.forms.js @@ -1,5 +1,12 @@ if (!window.MapEntity) window.MapEntity = {}; +// Disable button if submit event on form +Array.from(document.getElementsByClassName("mapentity-form")).forEach(function (formElement) { + formElement.addEventListener('submit', function () { + formElement.querySelector("button[type=submit]").setAttribute("disabled", true); + }, false); +}); + MapEntity.GeometryField = L.GeometryField.extend({ initialize: function () {