Class: Utils

FormView~ Utils

Utility class with various helper functions. These functions provide various utility operations related to form model creation and management.


new Utils()

Methods


<static> readData(element, clazz)

Returns the data attributes of the specific element. Ignores "data-cmp-is-" and "data-cmp-hook-" attributes.

Parameters:
Name Type Description
element Element

The element to read data attributes from.

clazz string

The class name.

Returns:

The data attributes.

Type
Object

<static> registerMutationObserver(formContainer, fieldCreator, fieldSelector, dataAttributeClass)

Registers the mutation observer for a form component.

Parameters:
Name Type Description
formContainer module:FormView~FormContainer

The form container.

fieldCreator function

The function to create a field.

fieldSelector string

The field selector.

dataAttributeClass string

The data attribute class.


<static> createFieldsForAddedElement(addedElement, formContainer)

Creates fields from all registered fieldCreators present inside addedElement, for given form container.

Parameters:
Name Type Description
addedElement Element

The added element.

formContainer module:FormView~FormContainer

The form container.


<static> setupField(fieldCreator, fieldSelector, fieldClass)

Execute a callback after the Form Container is initialized.

Parameters:
Name Type Description
fieldCreator function

The function to return an instance of FormField.

fieldSelector string

The CSS selector to identify the HTML element.

fieldClass string

The data attribute to read the field data from.


<static> removeFieldReferences(fieldView, formContainer)

Removes all references of field from views, Form Container.

Parameters:
Name Type Description
fieldView Object

The field view.

formContainer module:FormView~FormContainer

The form container.


<static> updateId(htmlElement, oldId, newId)

Update the id inside the given html element.

Parameters:
Name Type Description
htmlElement Element

The HTML element.

oldId string

The old ID.

newId string

The new ID.


<static> setContextPath(contextPath)

API to set the context path. All external HTTP API calls would by default prefix with this context path.

Parameters:
Name Type Description
contextPath string

The context path of the system.


<static> getContextPath()

API to get the context path.

Returns:
  • The context path of the system.
Type
string

<static> registerClickHandler(parentElement, hook, handler)

Registers handler on elements on hook.

Parameters:
Name Type Description
parentElement Element

The parent element.

hook string

The hook.

handler function

The event handler.


<async, static> registerCustomFunctions(formId)

Registers custom functions from clientlibs.

Parameters:
Name Type Description
formId string

The form ID.


<async, static> setupFormContainer(createFormContainer, formContainerSelector, formContainerClass)

Sets up the Form Container.

Parameters:
Name Type Description
createFormContainer function

The function to create a form container.

formContainerSelector string

The CSS selector to identify the form container.

formContainerClass string

The form container class.

Fires:

<static> stripIfWrapped(prefillJson)

For backward compatibility with older data formats of prefill services like FDM.

Parameters:
Name Type Description
prefillJson object

The prefill JSON object.

Returns:
  • The stripped prefill JSON object.
Type
object

<static> isUserAgent(agentName)

Checks if the current browser matches with the agentName passed.

Parameters:
Name Type Description
agentName string

The agent name to match with the browser's user agent.

Returns:
  • True if the browser's user agent matches the agentName, otherwise false.
Type
boolean