Choices and lists/A fixed table

Choices and lists

A fixed table

Opening hours are a table with a row for every day. People should fill it in, not add and remove days.

rows gives a list one row per option. No row can be added or removed, and each row is titled by its option. The key, here day, 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" },
      { code: "WED", label: "Wednesday" },
      { code: "THU", label: "Thursday" },
      { code: "FRI", label: "Friday" },
      { code: "SAT", label: "Saturday" },
      { code: "SUN", label: "Sunday" },
    ],
  },
  fields: [
    { key: "opens", type: "time", optional: true, label: "Opens" },
    { key: "closes", type: "time", optional: true, label: "Closes" },
  ],
},

Here item heads the first column, so it starts with a capital. The times are optional, so a café closed on Sunday leaves that row empty.

Add the list, fill in a few days, and open the Payload tab. Every row carries its day, [{ "day": "MON", "opens": "…", "closes": "…" }, …], so the API knows which hours are which.

Up nextAny, all and not