Module

useFormConfig

Methods

# async static fetchChoices(fieldId, url, object) → {Promise.<Array.<object>>}

Loads the data for the async fields
Parameters:
Name Type Description
fieldId string id of the field that is being loaded
url string url to load the data from
object FetchChoicesOptions url to load the data from

View Source hooks/useConfigForm.js, line 640

Promise.<Array.<object>>

# inner createRenderSection(section, fieldMap) → {FormSection}

Creates a section object for the form
Parameters:
Name Type Description
section object section object from the form layout
fieldMap Map.<string, Field> -

View Source hooks/useConfigForm.js, line 150

- Form section object
FormSection

# inner getUpdatedFields(triggerFields, fields, triggerId, formValue, options) → {Array}

Method to check for and setup conditional rendering
Parameters:
Name Type Description
triggerFields Map.<string, object> Map of fields that trigger conditional rendering
fields Map.<string, object> Map of all fields
triggerId string ID of the field to check
formValue any Value of the field to check
options object Options for the conditional rendering

View Source hooks/useConfigForm.js, line 79

- Array of fields that need to be updated
Array

# inner initTheForm(props)

Function to initialize the form
Parameters:
Name Type Description
props object
formLayout object Form layout object
setSections object React hook to set the sections
validations object Dynamic validations
setValidations object React hook to set the validations
isResetting boolean Whether or not the form is resetting
watchFields array Array of fields to watch
setFormProcessing object React hook to set the formProcessing state
setReadyForWatches object React hook to set the readyForWatches state
defaultValues object Default values for the form
options object Options object

View Source hooks/useConfigForm.js, line 353

# inner processConditionalUpdate(sections, fields, updatedFields, asyncThings, dynValid, resetFields) → {Array.<object>}

Process the updated fields and update the render sections
Parameters:
Name Type Description
sections Array.<FormSection> Array of all the sections in the form
fields Map.<string, object> Map of all the fields in the form
updatedFields Array.<object> Array of fields that need to be updated
asyncThings object Object of async things that need to be loaded
dynValid object Object of dynamic validations
resetFields object Object of fields that need to be reset

View Source hooks/useConfigForm.js, line 543

Array.<object>

# inner processDynamicFormLayout(formLayout, data) → {ProcessedDynamicFormLayout}

This function will take the form layout and the data and return the default values and validation schema for the form
Parameters:
Name Type Description
formLayout object
data object

View Source hooks/useConfigForm.js, line 24

- Object containing the default values, validation schema, and fields to watch for changes
ProcessedDynamicFormLayout

# inner renderTheSections(props)

Renders the sections
Parameters:
Name Type Description
props object Props object
sections array Array of sections
fields object Map of fields
triggerFields object Map of trigger fields
values object Form values
watchFields array Array of fields to watch
finishSetup function Function to finish setting up the form
options object Options object
fromWatch boolean Whether or not this is being called from a watch

View Source hooks/useConfigForm.js, line 402

# inner useConfigForm(formLayout, data, optionsopt, addCustomValidationsopt) → {object}

Any properties returned here may be applied to the FormContext for use in child components
Parameters:
Name Type Attributes Description
formLayout object Form layout object
data object Data to pre-populate the form with
options object <optional>
any other options needed for the form
addCustomValidations function <optional>
function to add custom validations to the form MUST return an object

View Source hooks/useConfigForm.js, line 179

- Object containing the useFormObject, formProcessing, and sections
object
Example
const { useFormObject, formProcessing, sections } = useConfigForm(formLayout, data, options);
<FormProvider {...useFormObject} sections={sections} formProcessing={formProcessing}>

Type Definitions

Object

# FetchChoicesOptions

Properties:
Name Type Description
urlDomain string domain to use when fetching the data
mappedId string property to use when mapping the id
mappedLabel string property to use when mapping the label
triggerFieldId string id of the field that triggered the load
choiceFormatter function function to format the choices
clearErrors function function to clear errors
setError function function to set errors

View Source hooks/useConfigForm.js, line 620