Problem: Fields in Aristotle are always shown and can’t include conditional values (eg. only show if another value is selected.
Feature: We are going to solve this using Custom Fields and JSON Forms in Aristotle
Snippets:
- When setting up a custom field, select the Structured Data (JSON) option
- Add a JSON Schema for the fields required, including a yes/no field to control the form. eg:
{
"type": "object",
"required": [
"external_custodian_exists"
],
"properties": {
"external_custodian_exists": {
"enum": [
"Yes",
"No"
],
"type": "string"
},
"external_custodian_details": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"phone": {
"type": "string"
},
"position": {
"type": "string"
},
"organisation": {
"type": "string"
}
}
}
}
}
- Include JSON Schema to conditionally hide or show extra fields:
{
"type": "HorizontalLayout",
"elements": [
{
"type": "Control",
"label": "Is there an External Custodian?",
"scope": "#/properties/external_custodian_exists",
"options": {
"format": "radio"
}
},
{
"rule": {
"effect": "SHOW",
"condition": {
"scope": "#/properties/external_custodian_exists",
"schema": {
"const": "Yes"
}
}
},
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/external_custodian_details/properties/name"
},
{
"type": "Control",
"scope": "#/properties/external_custodian_details/properties/organisation"
}
]
}
]
}
- This will provide an editor with optional fields that can be shown or hidden like below: