ebs.generateForm
Displays a predefined form or form driven flow that allows you to either add or edit a record for a given entity.
IMPORTANT!
If the form or form driven flow has multiple sections, the first page will be displayed.
If the form or form driven flow has multiple sections, the first page will be displayed.
The generated form or form driven flow does not include dedicated action handler buttons. The record is either inserted or edited when the parent form is saved.
Also see ebs.generateInsert, ebs.generateEdit, ebs.generateList.
Syntax
Copy
function ebs.generateForm(formDataArg: IEbsFormData, callback: any): void;
| Parameter | Type | Description |
|---|---|---|
formDataArg
|
IEbsFormData | Form settings. |
callback
|
any | Callback function to run after the form is generated. |
Type Aliases
JSON object containing settings for the form or form driven flow.
Copy
{
mainHtmlId: string;
entityName: string;
mode: string;
name?: string;
id?: string;
formName?: string;
pageNo?: number
}
| Property | Type | Description |
|---|---|---|
mainHtmlId
|
string | ID of the parent HTML element where the form or form driven flow will be injected. |
entityName
|
string | Name of the entity whose record will be inserted or edited. |
mode
|
string | Either insert or edit, depending on whether you want to insert a new record or edit an existing record. |
name(optional)
|
string | Assigns an ID to the generated form's HTML element. IMPORTANT! Make sure the ID is unique to avoid naming conflicts. |
id(optional)
|
string | If the form is in edit mode, you need to specify the ID of the record you wish to edit. |
formName(optional)
|
string | Name of the form or form driven flow. If left empty, the default insert/edit form or form driven flow associated with the entity is used. |
pageNo(optional)
|
number | Deprecated. |
Examples
In this example:
- We edit the page template of a form driven flow section to include an empty div element with the insertAccount ID and a custom button called addUser.
- In the section's After Generate tab, we include the following code that injects the default insert form of the Account entity in the div element when the button is clicked:
Copy
$('#addUser').on('click', function (event) {
ebs.generateForm({
'mainHtmlId' : 'insertAccount',
'entityName' : 'Account',
'mode' : 'insert'});
});
In this example:
- We edit the page template of a form driven flow section to include an empty div element with the editUser ID and a custom button called editThisUser.
- We use the formData.model method to retrieve the ID of the user record that is currently processed on the page (the userAccount attribute).
- In the section's After Generate tab, we include the following code that injects the default edit form of the Account entity in the div element when the button is clicked in order to edit the user account record on-demand:
Copy
$('#editThisUser').on('click', function (event) {
ebs.generateForm({
'mainHtmlId' : 'editUser',
'entityName' : 'Account',
'mode' : 'edit',
'id': formData.model.userAccount});
});