MDL-80608 core_form: Fire modal form event for errors in definition

The ERROR event is defined as being fired if an exception occurs while
contacting the server. This change ensures it is fired for exceptions
in the form definition AJAX request, not just form submission.

Additionally, if such an error occurs in submission, the form buttons
were left in disabled state. This change makes them enabled again.
This commit is contained in:
sam marshall
2024-02-14 13:49:39 +00:00
parent 328b48ebc5
commit 4bb42cc362
3 changed files with 9 additions and 5 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7 -3
View File
@@ -266,11 +266,12 @@ export default class ModalForm {
.then(response => {
pendingPromise.resolve();
return {html: response.html, js: Fragment.processCollectedJavascript(response.javascript)};
});
})
.catch(exception => this.onSubmitError(exception));
}
/**
* On exception during form processing. Caller may override
* On exception during form processing or initial rendering. Caller may override.
*
* @param {Object} exception
*/
@@ -409,7 +410,10 @@ export default class ModalForm {
}
return null;
})
.catch(exception => this.onSubmitError(exception));
.catch(exception => {
this.enableButtons();
this.onSubmitError(exception);
});
}
/**