Table Field

A table field allows to have another table “embedded” into the current table.

For example, think of an invoices and a invoiceItems tables. An entity-relationship diagram would be something like this:

Table field example diagram

We can implement this structure using table fields:

invoices.yml

key: invoices
type: table
name: Invoices
itemName: Invoice

summary:
  title: "Invoice {{number}}"

fields:
  date:
    type: date
    label: Invoice Date
  client:
    type: text
    label: Client
  items:
    type: table
    table: invoiceItems
    label: Items

invoiceItems.yml

key: invoiceItems
type: table
name: Invoice Items
itemName: Invoice Item

summary:
  title: "{{description}}"
  subtitle: "{{quantity}} units"

fields:
  quantity:
    type: integer
    label: Quantity
  description:
    type: text
    label: Description
  unitPrice:
    type: money
    label: Unit Price

Any table can be embedded into any other table. The only limitation is that you cannot have circular references.

The form for creating a new invoice, will then be presented like this:

Table field example form

Additionally, you can determine which columns of the child table you want to display, by using the columns property.

For example, the following will show only quantity and description:

# invoices.yml

fields:
  items:
    type: table
    table: invoiceItems
    label: Items
    columns:
      - quantity
      - description

More information in the YAML reference documentation.