aem-forms-af-runtime

Class: Form

Defines form model which implements form model

Hierarchy

Implements

Table of contents

Accessors

Methods

Properties

Accessors

:type

get :type(): string

Custom widget type show to the user for capturing the data.

Returns

string

Implementation of

FormModel.:type

Inherited from

Container.:type


action

get action(): undefined | string

Returns

undefined | string


activeChild

get activeChild(): null | BaseModel

Returns

null | BaseModel

Implementation of

FormModel.activeChild

Inherited from

Container.activeChild

set activeChild(c): void

Parameters

Name Type
c null | BaseModel

Returns

void

Implementation of

FormModel.activeChild

Inherited from

Container.activeChild


activeField

get activeField(): FieldModel

Retrieves the active field in the form.

Returns

FieldModel

The active field.

Implementation of

FormModel.activeField


captcha

get captcha(): null | FieldModel

Returns

null | FieldModel


changeEventBehaviour

get changeEventBehaviour(): "deps" | "self"

Returns

"deps" | "self"

Implementation of

FormModel.changeEventBehaviour


dataRef

get dataRef(): undefined | null | string

To map the field’s value to a property in the data model.

Returns

undefined | null | string

Implementation of

FormModel.dataRef

Inherited from

Container.dataRef


description

get description(): undefined | string

Extra description to be shown to the user to aid in form filling experience. It can be rich text.

Returns

undefined | string

Implementation of

FormModel.description

Inherited from

Container.description

set description(d): void

Extra description to be shown to the user to aid in form filling experience. It can be rich text.

Parameters

Name Type
d undefined | string

Returns

void

Implementation of

FormModel.description

Inherited from

Container.description


enabled

get enabled(): undefined | boolean

Whether the field is enabled and takes part in rules, events etc.

Returns

undefined | boolean

Implementation of

FormModel.enabled

Inherited from

Container.enabled

set enabled(e): void

Whether the field is enabled and takes part in rules, events etc.

Parameters

Name Type
e undefined | boolean

Returns

void

Implementation of

FormModel.enabled

Inherited from

Container.enabled


fieldType

get fieldType(): string

Type of field to capture the user data.

Returns

string

Implementation of

FormModel.fieldType

Inherited from

Container.fieldType


form

get form(): FormModel

Returns

FormModel

Overrides

Container.form


fragment

get fragment(): string

Returns

string

Implementation of

FormModel.fragment

Inherited from

Container.fragment


id

get id(): string

Id of the form.

Returns

string

Implementation of

FormModel.id

Overrides

Container.id


index

get index(): number

The index of the Field within its parent.

Returns

number

Implementation of

FormModel.index

Inherited from

Container.index


isContainer

get isContainer(): boolean

Whether the form field is container or not

Returns

boolean

Implementation of

FormModel.isContainer

Inherited from

Container.isContainer


isFragment

get isFragment(): boolean

Returns

boolean

Implementation of

FormModel.isFragment

Overrides

Container.isFragment


items

get items(): (FieldModel | FieldsetModel)[]

Defines the children/items of the container

Returns

(FieldModel | FieldsetModel)[]

Implementation of

FormModel.items

Inherited from

Container.items


label

get label(): undefined | Label

Label to be used for the field.

Returns

undefined | Label

Implementation of

FormModel.label

Inherited from

Container.label

set label(l): void

Label to be used for the field.

Parameters

Name Type
l undefined | Label

Returns

void

Implementation of

FormModel.label

Inherited from

Container.label


lang

get lang(): undefined | string

language of the field

Returns

undefined | string

Implementation of

FormModel.lang

Inherited from

Container.lang


logger

get logger(): Logger

Returns

Logger

Implementation of

FormModel.logger


maxItems

get maxItems(): number

Returns

number

Implementation of

FormModel.maxItems

Inherited from

Container.maxItems

set maxItems(m): void

Parameters

Name Type
m number

Returns

void

Implementation of

FormModel.maxItems

Inherited from

Container.maxItems


metaData

get metaData(): FormMetaData

Returns

FormMetaData


minItems

get minItems(): number

Returns

number

Implementation of

FormModel.minItems

Inherited from

Container.minItems

set minItems(m): void

Parameters

Name Type
m number

Returns

void

Implementation of

FormModel.minItems

Inherited from

Container.minItems


name

get name(): string

Name of the form field.

Returns

string

Implementation of

FormModel.name

Overrides

Container.name


parent

get parent(): ContainerModel

Defines the parent of the container

Returns

ContainerModel

Implementation of

FormModel.parent

Inherited from

Container.parent


properties

get properties(): Object

Custom properties of the form field.

Returns

Object

Implementation of

FormModel.properties

Inherited from

Container.properties

set properties(p): void

Custom properties of the form field.

Parameters

Name Type
p Object

Returns

void

Implementation of

FormModel.properties

Inherited from

Container.properties


qualifiedName

get qualifiedName(): string

Returns

string

Implementation of

FormModel.qualifiedName

Overrides

Container.qualifiedName


readOnly

get readOnly(): any

Whether the field should be readOnly to end user or not.

Returns

any

Implementation of

FormModel.readOnly

Inherited from

Container.readOnly

set readOnly(e): void

Whether the field should be readOnly to end user or not.

Parameters

Name Type
e any

Returns

void

Implementation of

FormModel.readOnly

Inherited from

Container.readOnly


repeatable

get repeatable(): any

Field is repeatable or not

Returns

any

Implementation of

FormModel.repeatable

Inherited from

Container.repeatable


ruleEngine

get ruleEngine(): RuleEngine

Returns

RuleEngine

Implementation of

FormModel.ruleEngine

Overrides

Container.ruleEngine


screenReaderText

get screenReaderText(): undefined | string

Returns

undefined | string

Inherited from

Container.screenReaderText


specVersion

get specVersion(): Version

Returns

Version

Implementation of

FormModel.specVersion


title

get title(): string

Form title.

Returns

string

Implementation of

FormModel.title


type

get type(): string

Returns

string

Implementation of

FormModel.type

Overrides

Container.type


uniqueItems

get uniqueItems(): undefined | boolean

Returns

undefined | boolean

Implementation of

FormModel.uniqueItems

Inherited from

Container.uniqueItems


value

get value(): null

The current value of the Field. The property is serialized in the Data Model.

Returns

null

Implementation of

FormModel.value

Overrides

Container.value


visible

get visible(): undefined | boolean

Whether the field should be visible to author or not.

Returns

undefined | boolean

Implementation of

FormModel.visible

Inherited from

Container.visible

set visible(v): void

Whether the field should be visible to author or not.

Parameters

Name Type
v undefined | boolean

Returns

void

Implementation of

FormModel.visible

Inherited from

Container.visible

Methods

_canHaveRepeatingChildren

_canHaveRepeatingChildren(mode?): boolean

Parameters

Name Type Default value
mode FormCreationMode 'create'

Returns

boolean

Inherited from

Container._canHaveRepeatingChildren


_findActiveField

_findActiveField(field): any

Parameters

Name Type
field null | FieldModel | FieldsetModel

Returns

any


addPromises

addPromises(updates): void

Parameters

Name Type
updates Promise<any>

Returns

void

Implementation of

FormModel.addPromises


change

change(event, context): void

Parameters

Name Type
event Action
context any

Returns

void

Inherited from

Container.change


executeAction

executeAction(action): void

Executes the given action

Parameters

Name Type Description
action Action event object

Returns

void

Inherited from

Container.executeAction


executeExpression

executeExpression(expr): any

Parameters

Name Type
expr string

Returns

any

Inherited from

Container.executeExpression


exportData

exportData(attachmentSerializedMap?): any

Exports the form data

Parameters

Name Type
attachmentSerializedMap Object

Returns

any

Implementation of

FormModel.exportData


exportSubmitMetaData

exportSubmitMetaData(): SubmitMetaData

Retrieve submit meta data of form.

function exportSubmitMetaData

property {string} lang - The language of the form.

property {Object} captchaInfo - The information about the CAPTCHA.

Returns

SubmitMetaData


focus

focus(): void

Returns

void

Inherited from

Container.focus


getDependents

getDependents(): string[]

Returns

string[]

Inherited from

Container.getDependents


getElement

getElement(id): FieldModel | FieldsetModel | Form

Get form element model based on the id of the form element

Parameters

Name Type
id string

Returns

FieldModel | FieldsetModel | Form

Implementation of

FormModel.getElement


getNonTransparentParent

getNonTransparentParent(): ContainerModel

Returns

ContainerModel

Inherited from

Container.getNonTransparentParent


getRules

getRules(): Items<string>

Returns

Items<string>

Inherited from

Container.getRules


getState

getState(forRestore?): TranslationBaseJson & RulesJson & TranslationConstraintsJson & { accept?: string[] ; enforceEnum?: boolean ; exclusiveMaximum?: number ; exclusiveMinimum?: number ; format?: string ; maxFileSize?: string | number ; maxItems?: number ; maxLength?: number ; maxOccur?: number ; maximum?: number ; minItems?: number ; minLength?: number ; minOccur?: number ; minimum?: number ; pattern?: string ; required?: boolean ; step?: number ; type?: string ; uniqueItems?: boolean ; validationExpression?: string } & { :type?: string ; altText?: string ; appliedCssClassNames?: string ; buttonType?: string ; constraintMessages?: ConstraintsMessages ; dataRef?: null | string ; enabled?: boolean ; errorMessage?: string ; fieldType?: string ; label?: Label ; lang?: string ; name?: string ; properties?: { [key: string]: any; } ; repeatable?: boolean ; screenReaderText?: string ; tooltip?: string ; viewType?: string ; visible?: boolean } & { activeChild?: string ; initialItems?: number ; items: (FieldJson | ContainerJson)[] } & { action?: string ; adaptiveform?: string ; data?: any ; lang?: string ; metadata?: MetaDataJson ; title?: string } & { :items: undefined = undefined; :itemsOrder: undefined = undefined; :type: string ; _dependents: undefined | string[] ; allowedComponents: undefined = undefined; columnClassNames: undefined = undefined; columnCount: undefined = undefined; enabled: undefined | boolean ; gridClassNames: undefined = undefined; id: string ; index: number ; items: any[] ; maxOccur: undefined | number ; minOccur: undefined | number ; parent: undefined = undefined; properties: { [key: string]: any; } ; qualifiedName: any ; readOnly: any ; repeatable: undefined | boolean = true }

Returns the current state of the form

To access the form data and attachments, one needs to use the data and attachments property. For example,

const data = form.getState().data
const attachments = form.getState().attachments

Parameters

Name Type Default value
forRestore boolean false

Returns

TranslationBaseJson & RulesJson & TranslationConstraintsJson & { accept?: string[] ; enforceEnum?: boolean ; exclusiveMaximum?: number ; exclusiveMinimum?: number ; format?: string ; maxFileSize?: string | number ; maxItems?: number ; maxLength?: number ; maxOccur?: number ; maximum?: number ; minItems?: number ; minLength?: number ; minOccur?: number ; minimum?: number ; pattern?: string ; required?: boolean ; step?: number ; type?: string ; uniqueItems?: boolean ; validationExpression?: string } & { :type?: string ; altText?: string ; appliedCssClassNames?: string ; buttonType?: string ; constraintMessages?: ConstraintsMessages ; dataRef?: null | string ; enabled?: boolean ; errorMessage?: string ; fieldType?: string ; label?: Label ; lang?: string ; name?: string ; properties?: { [key: string]: any; } ; repeatable?: boolean ; screenReaderText?: string ; tooltip?: string ; viewType?: string ; visible?: boolean } & { activeChild?: string ; initialItems?: number ; items: (FieldJson | ContainerJson)[] } & { action?: string ; adaptiveform?: string ; data?: any ; lang?: string ; metadata?: MetaDataJson ; title?: string } & { :items: undefined = undefined; :itemsOrder: undefined = undefined; :type: string ; _dependents: undefined | string[] ; allowedComponents: undefined = undefined; columnClassNames: undefined = undefined; columnCount: undefined = undefined; enabled: undefined | boolean ; gridClassNames: undefined = undefined; id: string ; index: number ; items: any[] ; maxOccur: undefined | number ; minOccur: undefined | number ; parent: undefined = undefined; properties: { [key: string]: any; } ; qualifiedName: any ; readOnly: any ; repeatable: undefined | boolean = true }

Implementation of

FormModel.getState

Overrides

Container.getState


getUniqueId

getUniqueId(): string

Returns

string

Implementation of

FormModel.getUniqueId


hasDynamicItems

hasDynamicItems(): boolean

returns whether the items in the Panel can repeat or not

Returns

boolean

Inherited from

Container.hasDynamicItems


importData

importData(dataModel): void

Imports the given form data

Parameters

Name Type
dataModel any

Returns

void

Implementation of

FormModel.importData

Overrides

Container.importData


indexOf

indexOf(f): number

Returns the index of the child item or the child container

Parameters

Name Type
f FieldModel | FieldsetModel

Returns

number

Implementation of

FormModel.indexOf

Inherited from

Container.indexOf


isTransparent

isTransparent(): boolean

Transparent form fields are meant only for creation of view. They are also not part of data

Returns

boolean

Implementation of

FormModel.isTransparent

Overrides

Container.isTransparent


isValid

isValid(): boolean

Checks if the given form is valid or not

Returns

boolean

true, if form is valid, false otherwise


notifyChildren

notifyChildren(action): void

Parameters

Name Type
action Action

Returns

void

Inherited from

Container.notifyChildren


resolveQualifiedName

resolveQualifiedName(qualifiedName): null | FieldModel | FieldsetModel

Resolves a form element by its qualified name.

see FieldModel

see FieldsetModel

Parameters

Name Type Description
qualifiedName string The qualified name to resolve.

Returns

null | FieldModel | FieldsetModel

The resolved form element, or null if not found.

Implementation of

FormModel.resolveQualifiedName


setAdditionalSubmitMetadata

setAdditionalSubmitMetadata(metadata): void

Parameters

Name Type
metadata Record<string, any>

Returns

void


setFocus

setFocus(field, focusOption): void

This function sets the focus to the field passed The field can be a panel or a form field. If a focusOption is specified along with a panel the navigation is restricted to that panel. If a focusOption is specified along with a field as input the navigation happens in the parent panel of that field.

Parameters

Name Type Description
field BaseModel can be a panel or a field.
focusOption FocusOption should be an enum of type FocusOption

Returns

void


validate

validate(): ValidationError[]

Validates the given form field

Returns

ValidationError[]

Implementation of

FormModel.validate

Overrides

Container.validate


visit

visit(callBack): void

visits each element in the form

Parameters

Name Type Description
callBack (field: FieldModel | FieldsetModel) => void a function which is invoked on each form element (including container type elements) visited

Returns

void

Implementation of

FormModel.visit


waitForPromises

waitForPromises(): Promise<void>

Returns

Promise<void>

Implementation of

FormModel.waitForPromises

Properties

_eventSource

_eventSource: EventSource = EventSource.CODE

Implementation of

FormModel._eventSource

Inherited from

Container._eventSource