Optional
checkboxOptions for CheckboxField type
Optional
cols?: 1 | 2 | 4Optional
fill?: "fill" | "outline"Optional
combinedOptions for CombinedRadioSelect type
Optional
dependentKey used to create the name for this child input (will be placed under <input.name>.
Label of the child component
Optional
childLabel options for the child component's label
Mapping of parent to child values
Key used to create the name for this parent input (will be placed under <input.name>.
Parent values
Type for the field (as matching backend)
Human readable label for the field
Optional
labelOptions for the text label
Internal name for the field (used in form state)
Optional
rulesValidation properties for the custom field
Optional
max?: number | { Optional
maxOptional
min?: number | { Optional
minOptional
pattern?: RegExp | { Optional
required?: boolean | { Optional
validate?: ((value, formValues) => undefined | string | boolean | string[] | Promise<ValidateResult>)Optional
selectExtra options for select inputs
Optional
initialWhen opening the pulldown, which value in the list to scroll to (top of the list by default)
Optional
valuesList of values Required for the following types:
Generated using TypeDoc
Definition for a custom field to place inside of a form dynamically
Usage in design system: In the design system for forms, extend the form's form data interface with a customFields key (can be any key name, but customFields is a good standard):
Then, extend the form's props with props that let you define custom fields:
Notice how instead of placing the list of custom fields on the top level, they are placed under a key (
foo
) that represents the location in the form where they should be placed. This is to allow for multiple locations in the form where custom fields can be placed.To make the form accept generics, you will need to change it to a non-anonymous function and add a generic type parameter with TFormCustomFields:
In the form component, you can render the custom fields by calling the renderFormCustomFields function.
Note that the first parameter is the list of custom fields to render, and the second parameter is the key in the form data where the custom fields should be placed.
Usage in Blocks:
In your createXBlock function, add a generic type parameter with TFormCustomFields. This will be defined by the user when using custom fields in the block.
To translate the definition labels from TCallbacks to strings, you can use the translateFormCustomFieldLabels function (defined separately in the i18n folder).
Then, finally, you can render the custom fields in the block view by passing them to the design system prop you made earlier.