Skip to content

Commit 19199b9

Browse files
rismehtaci-build
authored andcommitted
Adding support for form render event
1 parent d2c077d commit 19199b9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ui.frontend/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
******************************************************************************/
1616
import Utils from "./utils.js";
1717
import LanguageUtils from "./LanguageUtils.js";
18-
import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange} from "@aemforms/af-core";
18+
import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange, FormRendered} from "@aemforms/af-core";
1919
import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js";
2020
import {Constants} from "./constants.js";
2121
import GuideBridge from "./GuideBridge.js";
@@ -47,9 +47,10 @@ window.guideBridge = new GuideBridge();
4747
* @property {string} AddItem - The action for adding an item.
4848
* @property {string} RemoveItem - The action for removing an item.
4949
* @property {string} Save - The action for save event.
50+
* @property {string} FormRendered - The action for form rendered event.
5051
*/
5152
const Actions = {
52-
Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent
53+
Click, Change, Submit, Blur, AddItem, RemoveItem, UIChange, Save, CustomEvent, FormRendered
5354
}
5455

5556
/**

ui.frontend/src/utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import {Constants} from "./constants.js";
1818
import HTTPAPILayer from "./HTTPAPILayer.js";
1919
import {customFunctions} from "./customFunctions.js";
20-
import {FunctionRuntime} from '@aemforms/af-core';
20+
import {FunctionRuntime, FormRendered} from '@aemforms/af-core';
2121
import {loadXfa} from "./handleXfa";
2222
import RuleUtils from "./RuleUtils.js";
2323

@@ -355,6 +355,14 @@ class Utils {
355355
Utils.initializeAllFields(formContainer);
356356
const event = new CustomEvent(Constants.FORM_CONTAINER_INITIALISED, { "detail": formContainer });
357357
document.dispatchEvent(event);
358+
// Dispatch formRendered event after form is fully rendered
359+
if (formContainer && formContainer._model) {
360+
try {
361+
formContainer._model.dispatch(new FormRendered());
362+
} catch (error) {
363+
console.warn('Failed to dispatch formRendered event:', error);
364+
}
365+
}
358366
}
359367
}
360368
}

0 commit comments

Comments
 (0)