[FIX] website: reset a form properly for each submission success type
Before this commit, some behaviors of the forms after being submitted were problematic: - with the `On Success` option set on `Redirect`, when going back to a form after submitting it (with the browser arrows), the fields were still filled. - with the `Show Message` option selected, when going in edit mode when the message was displayed, the submit button was still "loading", even after saving. This commit solves this issues by properly resetting the form at each start and restoring the submit button loading effect when the message is displayed. task-2798576 closes odoo/odoo#118645 X-original-commit: ecb3bda77fab512a9790daf58447058f250f49e6 Signed-off-by: Vray Benjamin (bvr) <bvr@odoo.com> Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
This commit is contained in:
@@ -71,6 +71,10 @@ import { sprintf } from "@web/core/utils/strings";
|
||||
return res;
|
||||
},
|
||||
start: function () {
|
||||
// Reset the form first, as it is still filled when coming back
|
||||
// after a redirect.
|
||||
this.el.reset();
|
||||
|
||||
// Prepare visibility data and update field visibilities
|
||||
const visibilityFunctionsByFieldName = new Map();
|
||||
for (const fieldEl of this.el.querySelectorAll('[data-visibility-dependency]')) {
|
||||
@@ -364,7 +368,7 @@ import { sprintf } from "@web/core/utils/strings";
|
||||
|
||||
self.el.classList.add('d-none');
|
||||
self.el.parentElement.querySelector('.s_website_form_end_message').classList.remove('d-none');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// Prevent double-clicking on the send button and
|
||||
|
||||
Reference in New Issue
Block a user