Forms
Very often, you will need to ask for user inputs before triggering the logic behind an action.
For example, you might want to specify a reason if you want to block a user account. Or set the amount to charge a user’s credit card.
In the following example, an action form will be displayed for the "Charge credit card" action.
Form fields configuration
Static configuration
Form fields are statically configurable using the label
, type
, description
, isRequired
and isReadOnly
properties.
Dynamic configuration
Business logic often requires your forms to adapt to their context. Forest Admin makes this possible through a powerful way to extend your form's logic.
This can be done for the following properties:
Available as static configuration:
isRequired
,isReadOnly
,defaultValue
,enumValues
,collectionName
Additional properties:
if
,value
Example 1: Conditional field display based on record data
Success on social media can be based on the quality of your content but regardless on how hard you try, you will never be able to please everyone.
A good way to improve the mood is to ask only users which like your media to leave a review!
Here is how to do it in Forest Admin:
Example 2: Conditional enum values based on both record data and form values
In this example, the form will display a different set of enum values depending on both the record data and the value of the form field.
The first field displays different denominations that can be used to address the customer, depending on the full name and gender of the customer.
The second field displays different levels of loudness depending on if the customer is Morgan Freeman, as to ensure that we never speak Very Loudly
at him, for the sake of politeness.
Last updated