From 19199b93f410f788a5c21548c9c1de47cc31baef Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Thu, 4 Dec 2025 16:27:34 +0530 Subject: [PATCH 1/3] Adding support for form render event --- ui.frontend/src/index.js | 5 +++-- ui.frontend/src/utils.js | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui.frontend/src/index.js b/ui.frontend/src/index.js index 8ac52985ff..d71dfbc031 100644 --- a/ui.frontend/src/index.js +++ b/ui.frontend/src/index.js @@ -15,7 +15,7 @@ ******************************************************************************/ import Utils from "./utils.js"; import LanguageUtils from "./LanguageUtils.js"; -import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange} from "@aemforms/af-core"; +import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange, FormRendered} from "@aemforms/af-core"; import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; import {Constants} from "./constants.js"; import GuideBridge from "./GuideBridge.js"; @@ -47,9 +47,10 @@ window.guideBridge = new GuideBridge(); * @property {string} AddItem - The action for adding an item. * @property {string} RemoveItem - The action for removing an item. * @property {string} Save - The action for save event. + * @property {string} FormRendered - The action for form rendered event. */ const Actions = { - Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent + Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent, FormRendered } /** diff --git a/ui.frontend/src/utils.js b/ui.frontend/src/utils.js index 65431709d1..29e5bd194a 100644 --- a/ui.frontend/src/utils.js +++ b/ui.frontend/src/utils.js @@ -17,7 +17,7 @@ import {Constants} from "./constants.js"; import HTTPAPILayer from "./HTTPAPILayer.js"; import {customFunctions} from "./customFunctions.js"; -import {FunctionRuntime} from '@aemforms/af-core'; +import {FunctionRuntime, FormRendered} from '@aemforms/af-core'; import {loadXfa} from "./handleXfa"; import RuleUtils from "./RuleUtils.js"; @@ -355,6 +355,14 @@ class Utils { Utils.initializeAllFields(formContainer); const event = new CustomEvent(Constants.FORM_CONTAINER_INITIALISED, { "detail": formContainer }); document.dispatchEvent(event); + // Dispatch formRendered event after form is fully rendered + if (formContainer && formContainer._model) { + try { + formContainer._model.dispatch(new FormRendered()); + } catch (error) { + console.warn('Failed to dispatch formRendered event:', error); + } + } } } } From 77dd82a0180438a37a7a7128de0c5d00c00da578 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Sun, 14 Dec 2025 14:21:57 +0530 Subject: [PATCH 2/3] using custom event --- ui.frontend/src/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui.frontend/src/utils.js b/ui.frontend/src/utils.js index 29e5bd194a..c9e3b25b48 100644 --- a/ui.frontend/src/utils.js +++ b/ui.frontend/src/utils.js @@ -17,7 +17,7 @@ import {Constants} from "./constants.js"; import HTTPAPILayer from "./HTTPAPILayer.js"; import {customFunctions} from "./customFunctions.js"; -import {FunctionRuntime, FormRendered} from '@aemforms/af-core'; +import {FunctionRuntime, CustomEvent} from '@aemforms/af-core'; import {loadXfa} from "./handleXfa"; import RuleUtils from "./RuleUtils.js"; @@ -355,12 +355,12 @@ class Utils { Utils.initializeAllFields(formContainer); const event = new CustomEvent(Constants.FORM_CONTAINER_INITIALISED, { "detail": formContainer }); document.dispatchEvent(event); - // Dispatch formRendered event after form is fully rendered + // Dispatch custom:formViewInitialized event after form is fully rendered if (formContainer && formContainer._model) { try { - formContainer._model.dispatch(new FormRendered()); + formContainer._model.dispatch(new CustomEvent('formViewInitialized', {}, true)); } catch (error) { - console.warn('Failed to dispatch formRendered event:', error); + console.warn('Failed to dispatch custom:formViewInitialized event:', error); } } } From 589390e9e26529cf7d14a40ce350d10d210c5e60 Mon Sep 17 00:00:00 2001 From: Rishi Mehta Date: Sun, 14 Dec 2025 14:23:06 +0530 Subject: [PATCH 3/3] Removing Form render event --- ui.frontend/src/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui.frontend/src/index.js b/ui.frontend/src/index.js index d71dfbc031..8ac52985ff 100644 --- a/ui.frontend/src/index.js +++ b/ui.frontend/src/index.js @@ -15,7 +15,7 @@ ******************************************************************************/ import Utils from "./utils.js"; import LanguageUtils from "./LanguageUtils.js"; -import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange, FormRendered} from "@aemforms/af-core"; +import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange} from "@aemforms/af-core"; import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; import {Constants} from "./constants.js"; import GuideBridge from "./GuideBridge.js"; @@ -47,10 +47,9 @@ window.guideBridge = new GuideBridge(); * @property {string} AddItem - The action for adding an item. * @property {string} RemoveItem - The action for removing an item. * @property {string} Save - The action for save event. - * @property {string} FormRendered - The action for form rendered event. */ const Actions = { - Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent, FormRendered + Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent } /**