Skip to main content

foundation-forms.form

Home > @genesislcap/foundation-forms > Form

Form class​

Foundation form component for automatically generated forms based on json schema obtained from the api, supplied initial data or supplied JSON schema. Allowing customisable form elements using UI schema and set of custom renderers

submit - Fired when the form is submitted (includes payload and validation errors) submit-failure - Fired when submit fails (server or client validation) submit-success - Fired when submit succeeds submit-partial-success - Fired when bulk submit partially succeeds row-status-changed - Fired when row submit status changes bulk-submit-complete - Fired when bulk submit completes row-submit-failure - Fired when a single row submit fails row-submit-success - Fired when a single row submit succeeds data-change - Fired when form data changes csv-parse-error - Fired when CSV import parsing fails csv-imported - Fired when CSV data is imported successfully csv-template-error - Fired when CSV template cannot be generated csv-template-downloaded - Fired when CSV template is downloaded

Signature:

export declare class Form extends Form_base 

Extends: Form_base

Properties​

Property

Modifiers

Type

Description

additionalRenderers

RendererEntry[]

Allows to provide a set of additional renderers used by the form.

approvalMessageLabel

string

Label for the approval message field in the approval dialog.

bulkInsert

boolean

When enabled, transforms the form into bulk insert mode where multiple records can be added. The JSON schema will be wrapped as an array, and each item will be submitted separately.

bulkInsertMaxItems

number | undefined

Maximum number of items allowed in bulk insert mode. If not set, no maximum is enforced.

bulkInsertMinItems

number

Minimum number of items required in bulk insert mode.

confirmationMessage

string

Optional confirmation message to display before form submission. If set, a confirmation dialog will be shown when the user clicks submit.

data

any

Initial data for the form.

hideSubmit

boolean

Controls the visibility of the submit button.

jsonSchema

JSONSchema7

Alternatively to providing Form.resourceName you can hardcode the JSON schema on the client.

prefix

string

Name of the design system prefix that will be used in renderers.

readonly

boolean

Allows you to enable read-only mode, which disables all input on the form and hides the submit button.

renderers

RendererEntry[]

Allows to provide the main set of renderers used by the form. If not provided, the built-in renderers will be used by default.

resourceName

string

Name of the backend resource which will provide metadata used to generate form and later used for submitting data

rowSubmitStatuses

Map<number, BulkRowStatus>

Tracks the submission status for each row in bulk insert mode. Key is the row index, value is the status object.

setApprovalMessage

boolean

When enabled, adds an APPROVAL_MESSAGE field to the form schema. This field will be sent at root level alongside DETAILS when submitting.

uischema

UiSchema

UI schema used to define configuration of the layout and elements in the form Check UiSchema for possible options

Methods​

Method

Modifiers

Description

clearRowSubmitStatuses()

Clears all row submit statuses, typically called when resetting the form.

downloadCsvTemplate()

Downloads a CSV template file with headers and sample data based on the schema. If a UI schema is provided, it will be used to determine which fields to include and in what order. Hidden fields will be excluded from the template.

handleCsvFileSelected(event)

Handles CSV file selection for bulk import. Parses the CSV content and appends it to existing form items.

reset(clearData)

Reset the form state

submitSingleRow(index)

Submits a single row in bulk insert mode.