Skip to main content

DynamicForm

Purpose

The DynamicFormViewTemplate renders forms whose fields are generated dynamically at runtime. Instead of relying on a fixed set of EntityFields, it reads a JSON-based form definition and stores the submitted form data as JSON.

Behavior

Two fields are required for this ViewTemplate:

  • formDefinition, which contains the JSON-based field definition
  • formResult, which stores the submitted result as JSON

Both fields are typically backed by a JDitoRecordContainer.

Supported content types

The ViewTemplate supports the following field content types:

  • TEXT
  • NUMBER
  • DATE
  • BOOLEAN

Configuration

The formDefinition property must contain a JSON array of form objects. Each form object follows a structure such as the following:

{
"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"
}
}
}

The possibleItems property can be used for selectable options, for example in dropdown-based fields.

The following example shows a concrete form object:

{
"id": "propId",
"name": "propName",
"contentType": "TEXT",
"isReadable": true,
"isWritable": true,
"isRequired": false,
"possibleItems": {
"value1": "Value 1",
"value2": "Value 2"
}
}

Example usage

An example implementation is the ViewTemplate DynamicForm in WorkflowTaskForm_view.

The form is used in contexts that allow the creation and processing of WorkflowTask records. In such contexts, a Dashlet for WorkflowTasks is available. When a task is selected in WorkflowTaskPreview_view, the associated dynamic form can be displayed, filled out, and completed.