Lists

Lists

The same questions once per row, for as many rows as people need.

Rows people add

A list asks its fields once per row. item names one row, for the Add button and each row's heading. It is used mid-sentence, so write it in lowercase; headings capitalise it.

{
  key: "staff",
  type: "list",
  label: "Staff",
  item: "staff member",
  fields: [
    { key: "name", type: "text", label: "Full name" },
    { key: "role", type: "text", label: "Role" },
  ],
}
// staff: [{ name: "…", role: "…" }, …]

The fields in a row are ordinary fields: optional, when and checks work there, and a when names fields of the same row.

Try it in the tutorial: Rows people add.

How many

A required list needs one complete row, and an optional one needs none. min and max set the range; at max the Add button goes away.

{ key: "staff", type: "list", min: 2, max: 10, label, item, fields }

unique names a field whose answer may not repeat across rows:

{ key: "staff", type: "list", unique: "role", label, item, fields }

A table or a dialog

Rows are a table by default: one column per field, one line per row. A column is as wide as its field needs, a phone number wider than a name, and the table scrolls sideways when the columns do not fit. A header cut short shows in full on hover.

Rows with many fields read better one at a time. editor: "dialog" lists each row as a line and opens a dialog to add or edit it; wide: true gives that dialog more room.

{ key: "staff", type: "list", editor: "dialog", label, item, fields }

Try it in the tutorial: Rows in a dialog.

A fixed table

rows gives a list one row per option, to fill in rather than build. No row can be added or removed, and each row is titled by its option. The key is the name each row sends its option under.

{
  key: "hours",
  type: "list",
  label: "Opening hours",
  item: "Day",
  rows: {
    day: [
      { code: "MON", label: "Monday" },
      { code: "TUE", label: "Tuesday" },
    ],
  },
  fields: [
    { key: "opens", type: "time", label: "Opens" },
    { key: "closes", type: "time", label: "Closes" },
  ],
}
// hours: [{ day: "MON", opens: "…", closes: "…" }, { day: "TUE", … }]

Here item heads the first column, so it starts with a capital. Make the row's fields optional when a row may stay empty, like a day the café is closed; the row is still sent, with only its option.

Try it in the tutorial: A fixed table.

Each row's place

position sends each row's place, from 1, under the key it names, and reads saved rows back in that order.

{ key: "feeds", type: "list", position: "order", label, item, fields }
// feeds: [{ order: 1, … }, { order: 2, … }]

Fixed values on every row

payload on a list adds the same values to each row. Two lists can then send into one array, each row tagged with its list, and each reads back only its own rows. See Paths.

{ key: "local_staff", type: "list", at: "staff[]", payload: { origin: "LOCAL" }, label, item, fields }
{ key: "foreign_staff", type: "list", at: "staff[]", payload: { origin: "FOREIGN" }, label, item, fields }

Importing from a spreadsheet

import: true adds Download template and Import from Excel. The template's header row is the fields' labels. An .xlsx or .csv file is read into new rows, matched by header in any language or by key. Numbers, dates, yes or no and written options are read; files and dictionary choices are left for people to fill in. Imported rows are checked like typed ones.