Table Formfield (deprecated)
A table of rows, each made of tablefield columns
Deprecated. The
tablefield is replaced by the new list field combined with asubform. Thelistfield supports nested rows, reusable subforms shared across forms, and full-screen editing of each row. Existingtablefields keep working but will trigger a deprecation warning in the form.
A table field collects multiple records of structured data, where the columns of each row are defined by tablefields.
Properties
The properties available to a table 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: table (deprecated) |
| 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., |
| 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., |
| tableFields array | (deprecated) The list of fields in a table
Deprecated. The |
| data | |
| default many | Default value
The type of the value depends on the field type.
For |
| 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 |
| 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. |
| 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 |
| allowInsert boolean | Allow table/list insert
A table or list can be used to modify existing data. If new data is not allowed, set this property to false. Default: true |
| allowDelete boolean | Allow table/list delete
A table can be used to modify existing data. If you don’t was recoreds to be deleted, set this property to false. Default: true |
| readonlyColumns array | The readonly columns in table
With a tablefield, some fields might need to be readonly, like an |
| insertColumns array added in version 4.0.5 | The insert columns in table
With a tablefield, you can choose which fields are visible during insert. This way you can choose to hide certain fields. Use this property to set the insert fields. |
| showLoadButton boolean added in version 6.1.5 | Show load button for file import
Enables a “Load YAML” button that allows users to import data from .yml or .yaml files. For table fields, the YAML file must contain a valid array of objects. For yaml fields, the file can contain any valid YAML structure. Single objects are automatically wrapped in arrays for table fields. Default: false |
| showDownloadButton boolean added in version 6.1.5 | Show download button for file export
Enables a “Download” button that exports the field content as a .yml file. The filename is automatically generated from the field name. Default: false |
| output | |
| output boolean added in version 6.2.0 | Include field value as extravar
Form fields are by default sent as extravars. Note: Default: true |
| noOutput boolean | Do not output as extravar (deprecated)
Deprecated since 6.2.0. Use Default: false |
| model string or array | Extravar modelling
By default, a field is sent as a root-extravar. |
| deleteMarker string | Adds an additional deletemarker field
When you remove a record in a table, it gets removed. Since 6.4.1 the markers of a |
| insertMarker string | Adds an additional insertmarker field
When you add a record in a table, it simply gets added. |
| updateMarker string added in version 5.1.0 | Adds an additional updatemarker field
In addition to the insert and delete markers, you can also add an update marker. |
| 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 | |
| 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:
|
| tableTitleAdd string added in version 5.0.9 | Optional title for the table add action
When you add a record in a table, the default title is |
| tableTitleEdit string added in version 5.0.9 | Optional title for the table edit action
When you edit a record in a table, the default title is |
Examples
Example table fields, in YAML:
Table with default values
The field definition, in YAML:
- type: table
name: users
label: Users
default:
- username: john_doe
email: john@example.com
active: true
- username: jane_smith
email: jane@example.com
active: false
showLoadButton: true
showDownloadButton: true
tableFields:
- name: username
type: text
label: Username
required: true
- name: email
type: text
label: Email
required: true
- name: active
type: checkbox
label: Active
Table from expression
The field definition, in YAML:
- type: table
name: member
label: Add club members
expression: "[{department:'HR',firstname:'Ansible',lastname:'Guy',age:46,food:'veggies',paid:true}]"
allowInsert: true
allowDelete: true
insertMarker: isNewItem
deleteMarker: isRemovedItem
updateMarker: isUpdatedItem
readonlyColumns:
- department
- firstname
- lastname
- paid
required: true
tableFields:
- name: department
label: Department
type: enum
from: another_expression_array_field
columns: []
valueColumn: column_holding_value
previewColumn: column_as_preview
pctColumns: []
filterColumns: []
outputObject: false
- name: firstname
label: First Name
type: text
required: true
default: ""
minLength: 2
regex:
expression: "[a-zA-Z]*"
description: Must be normal characters
icon: user
- name: lastname
label: Last Name
type: text
required: true
default: ""
minLength: 5
- name: age
label: How old ?
type: number
required: true
default: 12
minValue: 12
maxValue: 80
- type: enum
name: food
label: Favorite food
default: veggies
values:
- pasta
- pizza
- fries
- steak
- veggies
- name: paid
label: membership
placeholder: Paid yet ?
type: checkbox
switch: true
required: true
default: true