Widgets in Forms
This is the official documentation of the @forestadmin/agent
Node.js agent.
Field Widgets empower your Actions Forms providing various options to display inputs and ease operators in their daily operations.
Widgets
Widget | Supported types | Minimal version | Description |
---|---|---|---|
| All types |
| Use the default widget |
|
| Display a text input with address autocomplete. | |
|
| Display a checkbox with true/false and possibly null values. | |
|
| Display a group of checkboxes to select multiple values. | |
|
| Display a color picker to select a color. | |
|
| Display a currency input. | |
|
| Display a calendar date picker | |
|
| Users can choose between a limited set of values. | |
|
| Users can upload files. | |
|
| Display a Json editor with syntax highlighting. | |
|
| Display a standard number input. | |
|
| Display a standard number input to enter a list of number values. | |
|
| Group of radio buttons to choose a value from. | |
|
| Rich text area allowing to input formatted text. | |
|
| Multi-line text area. | |
|
| One-line text input. | |
|
| One-line text input to enter a list of string values | |
|
| Input for entering a time | |
|
| Dropdown containing the users available in the current project |
Address autocomplete widget
The address autocomplete widget allows to input an address as a text value, autocompleted by the Google Maps API.
The above code will produce the following form (when empty):
And once the user starts typing:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string | optional |
| Placeholder shown in the component. |
Checkbox widget
The checkbox widget allows to activate or deactivate a boolean value.
The above code will produce the following form:
Options
The Checkbox
widget has no specific options, but its behavior can be customized using the following already existing options on fields:
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| boolean or | optional |
| Default value of the field. Define a value different from |
| boolean | optional |
| If |
By default, the Checkbox
widget allows 3 states:
null
true
false
To ensure having only 2 states, you need to:
set the
isRequired
option totrue
,define a value for the
defaultValue
option.
Checkbox group widget
The checkbox group widget allows to select multiple values from a list of options.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| An array if values, an array of value/label pairs, or a function receiving a context object returning this shape. | required |
| List of available options in the component. Supported formats:
|
Color picker widget
The color picker widget allows to select a color.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| boolean | optional |
| Allow users to select a color with an opacity. |
| string | optional |
| Placeholder shown in the component. |
| string | optional |
| List of colors to display in the quick palette. The list can be an array of hex colors or rgba colors. |
Currency input widget
The currency input widget allows to input a currency value.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string or a function returning a string (dynamic forms). | required |
| Currency code to display in the component. Valid currency ISO codes ↗ is required. |
|
| optional |
| Base unit to use for the value.unitValue is expressed in the currency's base unit.centValue is expressed as a hundredth of the base unit (typically in cents). |
| number or a function returning a number (dynamic forms). | optional |
| Minimum value allowed. |
| number or a function returning a number (dynamic forms). | optional |
| Maximum value allowed. |
| string | optional |
| Placeholder shown in the component. |
| number or a function returning a number (dynamic forms). | optional |
| Step between two values. |
DatePicker widget
The date picker widget allows to input a date in a form
The above code will produce the following form :
Note: using a Dateonly
field type will hide the time section from the date picker
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string or function returning a string | optional |
| The date picker uses |
| string | optional |
| Text will be shown as placeholder if the field is empty |
| Date or function returning a Date | optional |
| The minimum date allowed to be set in the field |
| Date or function returning a Date | optional |
| The maximum date allowed to be set in the field |
The dates are sent as ISO 8601 formatted strings over the network. In order to use them as Date
object in your hooks, you can parse them directly like so
Dropdown widget
The dropdown widget allows to select a value from a list of options.
The above code will produce the following form:
In this next example, we call a remote api to get a list of products and then perform a custom filter based on given fields of the json response, and return the first 25. This example uses search: 'dynamic'
dropdown widget, which provides you with the searchValue
in the callback context.
Note: when a search is performed, only the field on which it is performed will have its options recomputed.
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| Either an array of values, or an array of value/label pairs, or a function returning one of those arrays | required |
| List of available options in the component. Supported formats:
|
| string | optional |
| Placeholder shown in the component. |
|
| optional |
| Allow users to input text to filter values displayed in the dropdown.
- |
File picker widget
The file picker allows to upload files
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| An array of string values, or a function returning this shape | optional |
| The whitelist of file extensions allowed. If not specified, any file extension will be accepted |
| A number, or a function returning a number | optional |
| The max file size allowed to upload. Any file size is allowed if left empty. Make sure your server will be able to handle it. |
| A positive integer number, or a function returning this shape | optional |
| The max number of files allowed to be uploaded. If not specified, any number of files is allowed |
Number input widget
The number input widget allows to input a number value.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| number or a function returning a number (dynamic forms). | optional |
| Minimum value allowed. |
| number or a function returning a number (dynamic forms). | optional |
| Maximum value allowed. |
| string | optional |
| Placeholder shown in the component. |
| number or a function returning a number (dynamic forms). | optional |
| Step between two values. |
JSON editor widget
The JSON editor widget display a rich editor with syntax highlighting for JSON.
The above code will produce the following form:
Options
This widget does not have any options.
Number input list widget
The number input list widget allows to input a list of number values.
The above code will produce the following form (once the user entered two step values):
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| boolean | optional |
| Allow users to enter duplicate values. |
| boolean | optional |
| Allow users to enter empty values. |
| boolean | optional |
| Allow users to reorder values. |
| number | optional |
| Minimum value allowed. |
| number | optional |
| Maximum value allowed. |
| string | optional |
| Placeholder shown in the component. |
| number | optional |
| Step between two values. |
Radio group widget
The radio group widget allows to select a value from a list of options.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| An array if values, an array of value/label pairs, or a function receiving a context object returning this shape. | required |
| List of available options in the component. Supported formats:
|
Using the options
function, you can dynamically change the list of options based on the context, which contains information about the selected records and other values in the form. More info about dynamic configuration.
Rich text widget
The rich text widget allows to input a formatted text value.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string | optional |
| Placeholder shown in the component. |
Text area widget
The text area widget allows to input a multiline string value.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string | optional |
| Placeholder shown in the component. |
| number | optional |
| Widget's height expressed as a number of rows. |
Text input widget
The text input widget allows to input a string value.
The above code will produce the following form:
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string | optional |
| Placeholder shown in the component. |
Text input list widget
The text input list widget allows to input a list of string values.
The above code will produce the following form (once the user entered two tags):
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| boolean | optional |
| Allow users to enter duplicate values. |
| boolean | optional |
| Allow users to enter empty values. |
| boolean | optional |
| Allow users to reorder values. |
| string | optional |
| Placeholder shown in the component. |
Time picker widget
The time picker widget allows to select a time
The above code will produce the following form :
time picker does not support additional options
User dropdown widget
The user dropdown widget allows to input a user or list of users from the project
The above code will produce the following form (once the user has selected some users)
Options
Option | Type | Usage | Minimal version | Description |
---|---|---|---|---|
| string | optional |
| Placeholder shown in the component. |
Last updated