Table Formfield

A tabular data entry field for collecting multiple records with structured data, where each row contains nested tablefields.

Properties

Attribute Comments
basic
name
string / required / unique

Field name
Alfanumeric + underscore + dash

This attribute represents the name of the form field.

type
string / required

Field type

Other attributes might only be available for some field types.

Choices:
  • text
  • textarea
  • datetime
  • html
  • file
  • number
  • password
  • checkbox
  • radio
  • enum
  • expression
  • table
label
string

Field label
Free text

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., Label: $(fieldname)).

placeholder
string

In-field help value
Free text

Some form fields allow an in-field hint value.

Since 6.0.3: Supports placeholders for dynamic hints (e.g., Enter password (min $(minLength) chars)).

help
string

Field help message
Free text

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., This field depends on $(fieldname)).

tableFields
array

The list of fields in a table
Tablefield object

Every table field has its own separated table fields. The explanation of a tablefield requires a separate help.
You can read about tablefields here.

data
expression
string

A javascript expression.
Valid javascript

By default this javascript is evaluated on the server side and limited to predefined functions (for security). However in combination with runLocal, the evaluation is ran in the browsers sandbox and allows the full javascript power. When used in an enum field, the expression must return a flat array or array of flat objects, to make it presentable in a dropdown box.
An expression supports placeholders. Read more about placeholders here. [TODO] Click here to find out more about the predefined functions. [TODO]

tip : use the alias local (type=’expression’,runLocal=true,hide=true,noOutput=true)
tip : use the alias local_out (type=’expression’,runLocal=true,hide=true)
tip : use the alias credential (type=’expression’,runLocal=true,hide=true,asCredential=true)

runLocal
boolean

Run an expression locally

When running expressions, by default they are run remotely on the server.
But remote expressions are limited to predefined functions.
To unleash more javascript power, use this property.
The code will be evaluated in the sandbox of the browser, offloading the server, saving api-calls and making it more secure.

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.
We use a credential name to lookup the connection details. Legacy was to pass an object (name and type).
Since version 5.0.2 you can just specify the name of the credential. The type is fetched from the credential itself (mysql, mssql, postgres, oracle or mongodb). In case of no type set, mysql is assumed.
Additionally you can set an array of credential names, to use multiple databases with a single query. The result will be a join of the results.
Doubles will not be removed automatically.

query
string

The query to select data from a database
A valid sql query

This is typically a classic SELECT statement.
However, in the case of mongodb, the query is slightly different. See the examples.
An expression supports placeholders. Read more about placeholders here. [TODO]

interaction
dependencyFn
string
added in version 4.0.0

The dependency logical function

This attribute represents the logical function between multiple dependencies.

Choices:
  • and (default)
  • or
dependencies
list / elements=object

Show/hide this field based on the values or other fields
Reference to other formfields and their values

Each dependency element is either an object with the following 2 attributes:

  • name : holds the fieldname.
  • values : a list of valid values for the referenced field.

Or with the following 2 attributes:

  • name : holds the fieldname.
  • isValid : a boolean to check if the referenced is validated or not.

Use in combination with attribute dependencyFn.

allowInsert
boolean

Allow table insert

A table can be used to modify existing data. If new data is allowed, set this property to false.

Default:
true
allowDelete
boolean

Allow table 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 id field for example.
Use this property to set the readonly fields.

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.

output
noOutput
boolean

Do not output as extravar

Form fields are by default send as extravars.
If you do not want a field to be sent as extravar, set this attribute to true.

Default:
false
model
string or array

Extravar modelling
An dot-based string notation of an object, or an array of these

By default, a field is sent as a root-extravar.
If you want model the output of the extravars, you can specify a dot-notation of how this field should be modelled.

deleteMarker
string

Adds an additional deletemarker field

When you remove a record in a table, it gets removed.
When working with ansible and idempotency, the playbook never knew it got removed.
You need to explicitly set the status to absent.
So you can add a custom property to the deleted record, marking the record as deleted and sending it to the playbook for removal.

insertMarker
string

Adds an additional insertmarker field

When you add a record in a table, it simply gets added.
When working with ansible and idempotency, your playbook doesn’t know which records are new and which are not.
You might want to explicitly run a taks on only the new records.
So you can add a custom property to the inserted record, marking the record as new.

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:

  • field : The name of the referencing field
  • description : A validation message to show when the validation is not met. (Since 5.0.1: Supports placeholders for dynamic messages)

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:

  • field : The name of the referencing field
  • description : A validation message to show when the validation is not met. (Since 5.0.1: Supports placeholders for dynamic messages)

ignoreIncomplete
boolean

Allow form submit on non-evaluated placeholders

When an expression-based field has placeholders,
the default form behaviour is not to allow form submit until all placeholders are resolved. When this attribute is true, the form does not wait for placeholder completion for this field.

Default:
false
visualization
group
string

The field group name
Free text

With this attribute you can group fields together.
When all fields in a group are hidden (due to dependencies), the group is also hidden.

line
string
added in version 4.0.3

The field line name
Free text

With this attribute you can group fields in a single line together.
Use together with the width parameter to set the width, if not, the width is auto.

width
string
added in version 4.0.3

The field width
A valid Bootstrap Column width

With this attribute you can set the width of a field.
Use together wit the line parameter to put fields on 1 line. see https://getbootstrap.com/

Choices:
  • col-1
  • col-2
  • col-3
  • col-4
  • col-5
  • col-6
  • col-7
  • col-8
  • col-9
  • col-10
  • col-11
  • col-12
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 Add.
You can change this to something more meaningful by setting this property.

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 Edit.
You can change this to something more meaningful by setting this property.

name
string / required / unique

Field name
Alfanumeric + underscore + dash

This attribute represents the name of the form field.

type
string / required

Field type

Other attributes might only be available for some field types.

Choices:
  • text
  • textarea
  • datetime
  • html
  • file
  • number
  • password
  • checkbox
  • radio
  • enum
  • expression
  • table
label
string

Field label
Free text

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., Label: $(fieldname)).

placeholder
string

In-field help value
Free text

Some form fields allow an in-field hint value.

Since 6.0.3: Supports placeholders for dynamic hints (e.g., Enter password (min $(minLength) chars)).

help
string

Field help message
Free text

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., This field depends on $(fieldname)).

group
string

The field group name
Free text

With this attribute you can group fields together.
When all fields in a group are hidden (due to dependencies), the group is also hidden.

line
string
added in version 4.0.3

The field line name
Free text

With this attribute you can group fields in a single line together.
Use together with the width parameter to set the width, if not, the width is auto.

width
string
added in version 4.0.3

The field width
A valid Bootstrap Column width

With this attribute you can set the width of a field.
Use together wit the line parameter to put fields on 1 line. see https://getbootstrap.com/

Choices:
  • col-1
  • col-2
  • col-3
  • col-4
  • col-5
  • col-6
  • col-7
  • col-8
  • col-9
  • col-10
  • col-11
  • col-12
dependencyFn
string
added in version 4.0.0

The dependency logical function

This attribute represents the logical function between multiple dependencies.

Choices:
  • and (default)
  • or
dependencies
list / elements=object

Show/hide this field based on the values or other fields
Reference to other formfields and their values

Each dependency element is either an object with the following 2 attributes:

  • name : holds the fieldname.
  • values : a list of valid values for the referenced field.

Or with the following 2 attributes:

  • name : holds the fieldname.
  • isValid : a boolean to check if the referenced is validated or not.

Use in combination with attribute dependencyFn.

noLog
boolean
added in version 2.2.3

Disable backend logging

Disables logging in the backend, to hide passwords for example.

Default:
false
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:

  • field : The name of the referencing field
  • description : A validation message to show when the validation is not met. (Since 5.0.1: Supports placeholders for dynamic messages)

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:

  • field : The name of the referencing field
  • description : A validation message to show when the validation is not met. (Since 5.0.1: Supports placeholders for dynamic messages)

ignoreIncomplete
boolean

Allow form submit on non-evaluated placeholders

When an expression-based field has placeholders,
the default form behaviour is not to allow form submit until all placeholders are resolved. When this attribute is true, the form does not wait for placeholder completion for this field.

Default:
false
noOutput
boolean

Do not output as extravar

Form fields are by default send as extravars.
If you do not want a field to be sent as extravar, set this attribute to true.

Default:
false
model
string or array

Extravar modelling
An dot-based string notation of an object, or an array of these

By default, a field is sent as a root-extravar.
If you want model the output of the extravars, you can specify a dot-notation of how this field should be modelled.

expression
string

A javascript expression.
Valid javascript

By default this javascript is evaluated on the server side and limited to predefined functions (for security). However in combination with runLocal, the evaluation is ran in the browsers sandbox and allows the full javascript power. When used in an enum field, the expression must return a flat array or array of flat objects, to make it presentable in a dropdown box.
An expression supports placeholders. Read more about placeholders here. [TODO] Click here to find out more about the predefined functions. [TODO]

tip : use the alias local (type=’expression’,runLocal=true,hide=true,noOutput=true)
tip : use the alias local_out (type=’expression’,runLocal=true,hide=true)
tip : use the alias credential (type=’expression’,runLocal=true,hide=true,asCredential=true)

runLocal
boolean

Run an expression locally

When running expressions, by default they are run remotely on the server.
But remote expressions are limited to predefined functions.
To unleash more javascript power, use this property.
The code will be evaluated in the sandbox of the browser, offloading the server, saving api-calls and making it more secure.

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.
We use a credential name to lookup the connection details. Legacy was to pass an object (name and type).
Since version 5.0.2 you can just specify the name of the credential. The type is fetched from the credential itself (mysql, mssql, postgres, oracle or mongodb). In case of no type set, mysql is assumed.
Additionally you can set an array of credential names, to use multiple databases with a single query. The result will be a join of the results.
Doubles will not be removed automatically.

query
string

The query to select data from a database
A valid sql query

This is typically a classic SELECT statement.
However, in the case of mongodb, the query is slightly different. See the examples.
An expression supports placeholders. Read more about placeholders here. [TODO]

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 Add.
You can change this to something more meaningful by setting this property.

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 Edit.
You can change this to something more meaningful by setting this property.

allowInsert
boolean

Allow table insert

A table can be used to modify existing data. If new data is allowed, set this property to false.

Default:
true
allowDelete
boolean

Allow table 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
deleteMarker
string

Adds an additional deletemarker field

When you remove a record in a table, it gets removed.
When working with ansible and idempotency, the playbook never knew it got removed.
You need to explicitly set the status to absent.
So you can add a custom property to the deleted record, marking the record as deleted and sending it to the playbook for removal.

insertMarker
string

Adds an additional insertmarker field

When you add a record in a table, it simply gets added.
When working with ansible and idempotency, your playbook doesn’t know which records are new and which are not.
You might want to explicitly run a taks on only the new records.
So you can add a custom property to the inserted record, marking the record as new.

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.

readonlyColumns
array

The readonly columns in table

With a tablefield, some fields might need to be readonly, like an id field for example.
Use this property to set the readonly fields.

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.

tableFields
array

The list of fields in a table
Tablefield object

Every table field has its own separated table fields. The explanation of a tablefield requires a separate help.
You can read about tablefields here.

Examples

Table

- 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                                


Copyright © 2023-2026 AnsibleForms. All rights reserved.