Enum Formfield
A dropdown with search, for single or multiple choices
Properties
The properties available to a enum field, grouped by purpose:
| Attribute | Comments |
|---|---|
| basic | |
| name string / required / unique | Field name
This attribute represents the name of the form field. |
| type string / required | Field type
Other attributes might only be available for some field types. Value: enum |
| label string | Field label
A friendly name/label for the field. Note: if not set, the field name is used as label, but not when type is html. Since 6.0.3: Supports placeholders for dynamic labels (e.g., |
| placeholder string | In-field help value
Some form fields allow an in-field hint value. Since 6.0.3: Supports placeholders for dynamic hints (e.g., |
| help string | Field help message
Some fields require additional help information. This help message will be shown below the field. Since 6.0.3: Supports placeholders for dynamic help text (e.g., |
| data | |
| values array | A list of values
To manually populate an enum field |
| default many | Default value
The type of the value depends on the field type.
For |
| evalDefault boolean added in version 4.0.5 | Evaluates default value
A default can be treated as javascript and can thus hold expressions like Default: false |
| expression string | A javascript expression.
By default this javascript is evaluated on the server side and limited to predefined functions (for security). However in combination with tip: use the alias |
| runLocal boolean | Run an expression locally
When running expressions, by default they are run remotely on the server. Default: false |
| refresh boolean|string | Allow a manual or auto refresh
A query or expression is by default run once (if it doesn’t contain any dependencies). Default: false |
| dbConfig string, array or object | A database connection
When you want to query data from a database, you will need the proper connection information. |
| query string | The query to select data from a database
This is typically a classic SELECT statement. Every |
| jq string added in version 6.1.4 | Transform database query results with jq
Apply a jq expression to transform the result of a |
| multiple boolean | Allow multiple selection
When you want to select multiple items from a dropdown box, set this property to true. The field’s value is then a list of the selected items. Default: false |
| childrenColumn string added in version 7.9.0 | Show the rows as a tree that folds open
The key in a row that holds its child rows, an array of rows. The rows of the |
| valueColumn string | The column of a selected item that needs to exported as extravar
When you select an item in an new in v4.0.20: setting valueColumn to “*” will export all columns Default: first column |
| placeholderColumn string | The column of a selected item that is used in a placeholder
When you select an item in an New in v4.0.20: setting placeholderColumn to “*” will output the entire record, instead of a single column. Default: first column |
| interaction | |
| dependencyFn string added in version 4.0.0 | The dependency logical function
This attribute represents the logical function between multiple dependencies. Choices:
|
| dependencies list / elements=object | Show/hide this field based on the values or other fields
Each dependency element is either an object with the following 2 attributes:
Or with the following 2 attributes:
Use in combination with attribute |
| filterColumns array | The list of columns that you can filter on
By default the |
| sortable boolean added in version 7.9.0 | Sort the table by clicking a column header
An Default: true |
| selectableLevels array added in version 7.9.0 | Which levels of a tree can be selected
With Default: [0] |
| detailView string added in version 7.9.0 | Show the details of a row
Shows the details of a row, with more than its columns show (master/detail):
The details are the Default: none |
| detailTemplate string added in version 7.9.0 | The details of a row, as markdown
With |
| detailColumns array added in version 7.9.0 | The columns the details of a row show
With |
| output | |
| output boolean added in version 6.2.0 | Include field value as extravar
Form fields are by default sent as extravars. Default: true |
| model string or array | Extravar modelling
By default, a field is sent as a root-extravar. |
| asCredential boolean | Send credential as extravar
Use the value of this field to search for a credential with the same name Since 4.0.16, you can use this in combination with the Default: false |
| outputObject boolean | Output the selection of a enum-field as a full object.
When selecting from an New in v4.0.20: valueColumn: “*” has the same behavior, and will output all columns Default: false |
| security | |
| noLog boolean added in version 2.2.3 | Disable backend logging
Disables logging in the backend, to hide passwords for example. Default: false |
| validation | |
| required boolean | Required field
Makes the field required. Default: false |
| validIf object added in version 2.2.4 | An field based validation (field must be true)
Enforces a validation where a referencing (expression) field must be true. This field requires an object with 2 attributes:
|
| validIfNot object added in version 2.2.4 | An field based validation (field must be false)
Enforces a validation where a referencing (expression) field must be false. This field requires an object with 2 attributes:
|
| ignoreIncomplete boolean | Allow form submit on non-evaluated placeholders
When an expression-based field has placeholders, Default: false |
| visualization | |
| icon string | Field icon
Some formfields can hold a nice looking icon. The icon name is a free fontawesome 6 icon. You can find more information at www.fontawesome.com |
| group string | The field group name
With this attribute you can group fields together. |
| line string added in version 4.0.3 | The field line name
With this attribute you can group fields in a single line together. |
| width string added in version 4.0.3 | The field width
With this attribute you can set the width of a field. Choices:
|
| sticky boolean | Make a dropdown box permanently visible
A Default: false |
| horizontal boolean added in version 4.0.3 | Converts a dropdown box to a horizontal selector
A Default: false |
| columns array | The list of columns visible in the dropdown/table
For an |
| pctColumns array | The list of columns that should visualized as a percentage-bar
By default all properties are show with its regular value. |
| previewColumn string | The column of the selected item(s) that is shown in the dropdown-preview
When you select an item in an Default: first column |
Trees
Rows can hold rows of their own: a group with its jobs, a datacenter with its clusters and their hosts. Name the key that holds them in childrenColumn and the enum shows a tree that folds open, as deep as the data goes. With one column it looks like a tree, with several like a table whose rows fold open.
- name: groups
type: enum
sticky: true
multiple: true
childrenColumn: jobs
columns: [name, description, owner]
valueColumn: name
values:
- name: nightly
description: Nightly jobs
jobs:
- { name: backup-db, description: Back up the databases, owner: dba }
- { name: rotate-logs, description: Rotate the logs, owner: ops }
- name: weekly
description: Weekly jobs
jobs:
- { name: patch, description: Patch the servers, owner: ops }
- A caret folds a row open or closed; the rows start folded.
- The columns are those of the rows on every level: a job can show a column its group lacks.
columnsstill picks and orders them. - Typing in the search box shows the rows that match, with the rows above them unfolded.
- A column header sorts each level on its own; the children stay under their parent.
- A selected row is sent as it is, its children included. Use
valueColumnormodelto send only part of it.
The rows usually come from an expression or a query, jq can shape them, as long as each row holds its children under the same key.
Which levels can be selected
selectableLevels lists the levels a user can select: 0 is the top level, 1 its children, 2 theirs. It is [0] by default. A row on another level is muted, and a click on it only folds it open or closed.
- name: jobs
type: enum
sticky: true
multiple: true
childrenColumn: jobs
selectableLevels: [1]
columns: [name, description]
valueColumn: name
expression: "fn.fnReadJsonFile('/app/dist/persistent/jobgroups.json')"
With multiple, a row that cannot be selected gets a box of its own when there are rows below it that can: it selects all of them, or none when they all are, and shows whether all, some or none are selected. Above, a click on the box of nightly selects all its jobs; the value holds the jobs, never the group. The box in the header selects every row that can be selected, folded or not.
Selecting a row never selects its children. When several levels can be selected ([0, 1]), the value can hold rows of different levels.
Details
A row can show more than its columns. detailView sets where:
row: each row gets an info icon at its end, and a click on it opens the row’s details under the row.split: the rows on the left, the details of the row clicked last on the right. For astickyenum; a dropdown shows them as withrow.
Without anything else, the details are the row on its side: each column with its value. A column holding a list of objects shows as a small table, so a group shows its jobs. detailColumns picks and orders the columns.
- name: groups
type: enum
sticky: true
columns: [name]
valueColumn: name
detailView: split
detailColumns: [description, jobs]
values: ...
A template
detailTemplate writes the details in markdown, html inside it allowed. $(column) is filled from the row; a path goes deeper, $(owner.name) or $(disks[0].dev), and $(.) is the row itself when it is not an object.
- name: servers
type: enum
sticky: true
columns: [name, os]
valueColumn: name
detailView: split
detailTemplate: |
### $(name)
**OS**: $(os) - **owner**: $(owner.name)
| disk | GB |
|---|---|
| $(disks[0].dev) | $(disks[0].gb) |
_$(notes)_
expression: "fn.fnReadJsonFile('/app/dist/persistent/servers.json')"
The values of the row are encoded and the result is sanitized: data never becomes html, and the template keeps only what is safe, no scripts and no event handlers.
Trees and details go together: with childrenColumn and detailView, every row, on every level, has its details.
Examples
Example enum fields, in YAML:
Queries
The field definition, in YAML:
since queries are so diverse, there is a separate section on queries with examples.