DynamicForm
The DynamicFormViewTemplate is a type of ViewTemplate that enables the creation of dynamic forms within ADITO. Unlike conventional forms that rely on predefined EntityFields, the fields of a DynamicForm are generated dynamically at runtime using a JSON-based field definition.
Usage Context
Example Implementation
An example implementation of this ViewTemplate is DynamicForm as used in WorkflowTaskForm_view.
Appearance in the Client
The DynamicForm appears in all Contexts that allow the user to create a WorkflowTask. In these Contexts, a Dashlet is available for WorkflowTasks. When a specific task is selected in the WorkflowTaskPreview_view, the associated form can be displayed, filled out, and the task can then be finalized.
Configuration
To configure a DynamicFormViewTemplate, two properties must be defined:
formDefinition
This property references an EntityField that provides the JSON string containing the form field definitions.
The data source for this EntityField is typically a JDitoRecordContainer.
formResult
This property specifies the target EntityField that stores the results of the form after it has been saved. The data is stored in JSON format.
As with formDefinition, the data source for this EntityField is usually a JDitoRecordContainer.
Supported Content Types
The DynamicFormViewTemplate supports the following content types for form fields:
TEXTNUMBERDATEBOOLEAN
JSON Field Definition
The formDefinition property must contain a JSON array of form objects. Each form object describes a single form field and adheres to a consistent structure, as shown below.
Structure of a Form Object
{
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"contentType": { "type": "string" },
"isReadable": { "type": "boolean" },
"isWritable": { "type": "boolean" },
"isRequired": { "type": "boolean" },
"value": { "type": "string" },
"possibleItems": {
"type": "object"
// Format: key(string) : value(string)
}
}
}
The possibleItems property can be used to define a list of selectable options, useful for dropdowns or selection fields.
Example Configuration Pattern
The following is an example of a JSON form object that defines a readable and writable text field with optional selection values.
{
"id": "propId",
"name": "propName",
"contentType": "TEXT",
"isReadable": true,
"isWritable": true,
"isRequired": false,
"possibleItems": {
"value1": "Value 1",
"value2": "Value 2"
}
}
Figure: Example configuration of a DynamicForm field with selectable options