MDL-76667 forms: mark modal form as submitted upon success.

Ensure the form change checker module doesn't warn user about it.
This commit is contained in:
Paul Holden 2022-12-13 08:44:08 +00:00
parent 6b24f59302
commit 0d20d1e8aa
3 changed files with 8 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -269,13 +269,13 @@ export default class ModalForm {
*/
notifyResetFormChanges() {
const form = this.getFormNode();
FormEvents.notifyFormSubmittedByJavascript(this.getFormNode(), true);
if (!form) {
return;
}
FormChangeChecker.resetFormDirtyState(this.getFormNode());
FormEvents.notifyFormSubmittedByJavascript(form, true);
FormChangeChecker.resetFormDirtyState(form);
}
/**
@ -358,7 +358,8 @@ export default class ModalForm {
this.disableButtons();
// Convert all the form elements values to a serialised string.
const formData = this.modal.getRoot().find('form').serialize();
const form = this.modal.getRoot().find('form');
const formData = form.serialize();
// Now we can continue...
Ajax.call([{
@ -379,7 +380,7 @@ export default class ModalForm {
} else {
// Form was submitted properly. Hide the modal and execute callback.
const data = JSON.parse(response.data);
this.notifyResetFormChanges();
FormChangeChecker.markFormSubmitted(form[0]);
const event = this.trigger(this.events.FORM_SUBMITTED, data);
if (!event.defaultPrevented) {
this.modal.hide();