Expression 字段
由 JavaScript 计算得出的值,可在浏览器中,也可在服务器上计算
属性
expression 字段可用的属性,按用途分组:
| 属性 | 说明 |
|---|---|
| basic | |
| name string / 必填 / 唯一 | Field name
This attribute represents the name of the form field. |
| type string / 必填 | Field type
Other attributes might only be available for some field types. 值: expression |
| 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 | |
| value any 在版本 4.0.17 中添加 | A fixed value (any type) for the expression
To manually populate an expression field (dictionary, array, number, boolean, string). |
| default many | Default value
The type of the value depends on the field type.
For |
| evalDefault boolean 在版本 4.0.5 中添加 | Evaluates default value
A default can be treated as javascript and can thus hold expressions like 默认值: 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. 默认值: 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). 默认值: false |
| editable boolean | Makes an expression editable
An expression is by default readonly. 默认值: 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 在版本 6.1.4 中添加 | Transform database query results with jq
Apply a jq expression to transform the result of a |
| interaction | |
| dependencyFn string 在版本 4.0.0 中添加 | The dependency logical function
This attribute represents the logical function between multiple dependencies. 选项:
|
| 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 |
| output | |
| output boolean 在版本 6.2.0 中添加 | Include field value as extravar
Form fields are by default sent as extravars. 默认值: 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 默认值: false |
| security | |
| noLog boolean 在版本 2.2.3 中添加 | Disable backend logging
Disables logging in the backend, to hide passwords for example. 默认值: false |
| validation | |
| required boolean | Required field
Makes the field required. 默认值: false |
| minLength number | Field minimum length
Forces a string-field to be at least x long. Since 6.0.3: Supports placeholders for dynamic validation (e.g., |
| maxLength number | Field maximum length
Forces a string-field to be maximum x long. Since 6.0.3: Supports placeholders for dynamic validation (e.g., |
| regex object | A regular expression validation
Enforces a validation where the current field must match a regular expression. This field requires an object with 2 attributes:
|
| notIn object 在版本 2.2.4 中添加 | A list validation (can not be in list)
Enforces a validation where the current field can not be one of the values in a list (referencing another field). This field requires an object with 2 attributes:
|
| in object 在版本 2.2.4 中添加 | A list validation (must be in list)
Enforces a validation where the current field must be one of the values in a list (referencing another field). This field requires an object with 2 attributes:
|
| validIf object 在版本 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 在版本 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:
|
| sameAs string | An field based validation (field must be same as other field)
Enables a validation where the value of this field must match the value of another field. Perfect for password entry, for example. |
| ignoreIncomplete boolean | Allow form submit on non-evaluated placeholders
When an expression-based field has placeholders, 默认值: 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 在版本 4.0.3 中添加 | The field line name
With this attribute you can group fields in a single line together. |
| width string 在版本 4.0.3 中添加 | The field width
With this attribute you can set the width of a field. 选项:
|
| isHtml boolean | Renders text as html
If an expression value has html tags (for example ), it will render the value as such. The html is sanitized before it is rendered: 默认值: false |
| hide boolean | Hides an expression field
Set to 默认值: false |
示例
expression 字段示例(YAML):
Expressions
字段定义(YAML):
since expressions are so diverse, there is a separate section on expressions with examples.