Form Template

Developer page

Template manager page

Form Templates *.json File Structure

Which template properties are available in a model .json definition file, or in a form .json definition file?

  • For data models templates structure, see here.
  • For forms templates structure, see this file. For reference, also open this file cores.json to the side, in a new browser window.

In the table below, the values in column "Property" correspond to keys in a *.json* file, e.g. backend/dis_templates/forms/cores.json. They can also be found as props in *.vue files, e.g. src/forms/CoresForm.vue.generated.

The key ordering in the .json file is arbitrary, and can deviate from this order.

Property Type Required Nullable
name string Yes No
dataModel string Yes No
fields array of Field Yes No
filterDataModels object see details. Yes No
requiredFilters array of RequiredFilter Yes No
subForms object see details. Yes No
supForms object see details. Yes No
group string Yes No
order integer Yes No
createdAt number No Yes
modifiedAt number No Yes
generatedAt number No Yes

Form name

The name of the module that this model belongs to or, in other words, the table groups that this table belongs to.

  • is required
  • type: string
  • case: kebab-case

Form dataModel

The name of the data model that the form manages e.g. CoreCore

  • is required
  • type: string

Form fields

An array of fields definitions that the form has. Every object of this array is of Field type. The array must have at least fields for the required fields of the table.

  • is required
  • type: array of Field

Field Definition

Property Type Required Nullable
name string Yes No
label string Yes No
group string Yes No
order string Yes No
description string No Yes
validators array of Validator Yes No
formInput object of FormInput Yes No

Field name

The name of the field is the name of the column it edits. This name is copied automatically from the model template when using the template manager.

  • is required
  • type: string

Field label

The label of the field is copied automatically from the model template when using the template manager.

  • is required
  • type: string

Field group

The name of the group. if the name starts with -, the group name will not be shown on the generated form.

  • is required
  • type: string

Field order

The order of the field in the group it belongs to.

  • is required
  • type: integer

Field description

This value will be shown as a hint under the fields in the generated form. This value is also copied automatically from the model template when using the template manager.

  • is required
  • type: string

Field validators

An array of validators for the field. Every object of this array is of Validator type. An empty array is also accepted.

These validators are independent from, and simpler than, data model validation. The real validation happens on the backend when submitting the form. On the frontend only three validators are available: required, string and number.

Validator Definition
Property Type Required Nullable
type string Yes No
max number No No
min number No No
Validator type

The type must be one of the following values: required, string or number.

  • is required
  • type: string
Validator max

This value works with string and number validators only and represents that maximum string length in string validator and the largest number the field could have for number validator.

  • is optional
  • type: number
Validator min

This value works with number validator only and represents that smallest number the field could have for number validator.

  • is optional
  • type: number

Field formInput

Defines the type of the input that should be used to edit the matching field/column. The value of this field should be a FormInput type.

  • is required
  • type: object
FormInput Definition
Property Type Required Nullable
type string Yes No
disabled boolean No No
readOnly boolean No No
calculate string No Yes
allowFreeInput boolean No No
multiple boolean No No
selectSource object No No
FormInput type

Defines the input type for this field. The type can be one of the following values: text, textarea, switch, select, date, time or datetime

depending on the type of the input, other options are possible in the FormInput Definition. allowFreeInput, multiple and selectSource works only with the type select otherwise they will be ignored.

  • is required
  • type: string
FormInput disabled

Determines if the input should be disabled or not.

  • is optional
  • type: boolean
FormInput readOnly

Determines if the input should be read only or not.

  • is optional
  • type: boolean
FormInput calculate

This value has the same value in the model template, see here, and it will be copied automatically when using the template manager.

  • is optional
  • type: string
FormInput allowFreeInput

Determines whether the user is able to write a value that does not already exists in the list.

Only for select form input type.

  • is optional
  • type: boolean
FormInput multiple

Determines whether the user is able choose more than one value from the list.

Only for select form input type.

  • is optional
  • type: boolean
FormInput selectSource

Defines the source from which the list items should be loaded. For now only one source is supported which is the list from the ListValues data model.

Only for select form input type.

  • is required when input type is select
  • type: string
Example

since version 1.2.0-beta.0 (opens new window) There are two types of select sources: list and api. If list is the type of the select source then the list of options will be generated from the list_values table based on the value of listName. In this case, the values of textField and valueField must be remark and display an in the following example.

{
    "selectSource": {
        "type": "list",
        "listName": "ANALYST", <--- the name of the list in ListValues data model
        "textField": "remark",
        "valueField": "display"
    }
}
1
2
3
4
5
6
7
8

If api is the type of the select source them the list of options will be generated from the model defined in the corresponding property. In this case textField and valueField values must be a name of a column that belongs to the defined model's table. textField and valueField can be identical.

{
    "selectSource": {
        "type": "api",
        "model": "ProjectHole",
        "textField": "hole",
        "valueField": "id"
    }
}
1
2
3
4
5
6
7
8

Form filterDataModels

This field defines the filter components that will be generated in the filter form at the top of the form. This value will be automatically generated when using the template manager.

the order is important

  • is required
  • type: object of (key, value) pairs
    • key: is a unique string for the filter component. This string will be used as the label of the filter input
    • value: is an object of FilterDataModel type

FilterDataModel Definition

Defines the filter components data source and relation to other components.

Property Type Required Nullable
model string Yes No
value string Yes No
text string Yes No
ref string Yes No
require object Yes No

FilterDataModel model

The name of the data model of which the list items will be loaded.

  • is required
  • type: string

FilterDataModel value

The name of the data model field which should be mapped as a list item value.

  • is required
  • type: string

FilterDataModel text

The name of the data model field which should be mapped as a list item text.

  • is required
  • type: string

FilterDataModel ref

The name of the field of the data model needed to be filtered. the value of the filter component will be compared with this field.

  • is required
  • type: string

FilterDataModel require

This field defines the dependency of the filter component. Dependency means the filter list items relations e.g. hole list items changes when the selected item in the site filter component changes.

  • is optional
  • type: object

This relation is defined as follows:

{
    "require": {
        "value": "...",
        "as": "..."
    }
}
1
2
3
4
5
6
  • value: defines which filter component value to use to filter the dependent list (one of the filterDataModels keys)
  • as: defines against which field of the dependent list's data model should this list be filtered upon.

Form requiredFilters

This array defines the minimum fields that are required to be sent when submitting a form. Every item of the array should be of RequiredForm object.

RequiredForm Definition

{
    "requiredFilters": [
        {
            "value": "hole",
            "as": "hole_id"
        }
    ]
}
1
2
3
4
5
6
7
8
  • value: which filter component value is required (on of filterDataModels keys)
  • as: the field name of this value to be sent when submitting the form.

Form subForms

Will be generated automatically in the template manager depending on the selected child forms.

  • is optional
  • type: object of (key, value) pairs
    • key: is a unique key (preferably the name of the form)
    • value: is an object of SubForm type

SubForm Definition

Property Type Required Nullable
buttonLabel string Yes No
url string Yes No
filter array Yes No

SubForm buttonLabel

The label of the child form button in the form.

  • is required
  • type: string

SubForm url

The target form url

  • is required
  • type: string

SubForm filter

An array of objects that defines the values of the filter components to append to the url.

  • is required
  • type: array of object. Every object has two properties:
    • unit: string defines the filter component (one of filterDataModels of the target form template)
    • formField: string defines which value of the selected item which is loaded in the form should be set to this filter component

Form supForms

Will be generated automatically in the template manager depending on the selected parent forms.

  • is optional
  • type: object of (key, value) pairs
    • key: is a unique key (preferably the name of the form)
    • value: is an object of SupForm type

SupForm Definition

Property Type Required Nullable
buttonLabel string Yes No
url string Yes No
parentIdField string Yes No
filter array Yes No

SubForm buttonLabel

The label of the parent form button in the form.

  • is required
  • type: string

SubForm url

The target form url

  • is required
  • type: string

SubForm parentIdField

Which field value should be passed as the selected item id of the parent form

  • is required
  • type: string

SubForm filter

An array of objects that defines the values of the filter components to append to the url.

  • is required
  • type: array of object. Every object has two properties:
    • unit: string defines the filter component (one of filterDataModels of the target form template)
    • formField: string defines which value of the selected item which is loaded in the form should be set to this filter component

Form createdAt

A timestamp of when the template was created

  • is optional
  • type: integer

Form modifiedAt

A timestamp of when the template was modified

  • is optional
  • type: integer

Form generatedAt

A timestamp of when the template was generated

  • is optional
  • type: integer