Skip to content
bahtuiv0.18.8

<baht-repeater>

Array-of-rows control: every row renders the same sub-fields, one level deep. Edits emit the whole array.

Rows of sub-fields

Inside <baht-form> you never touch this element: a field with type "repeater" and fields[] renders it.

<baht-repeater></baht-repeater>

<script>
  const el = document.querySelector('baht-repeater');
  el.field = {
    "order": 1,
    "type": "repeater",
    "key": "servers",
    "label": "Servers",
    "fields": [
      {
        "order": 1,
        "type": "text",
        "key": "host",
        "label": "Host",
        "width": "1/2"
      },
      {
        "order": 2,
        "type": "dropdown",
        "key": "env",
        "label": "Environment",
        "width": "1/2",
        "options": [
          {
            "key": "prod",
            "label": "Production"
          },
          {
            "key": "stage",
            "label": "Staging"
          }
        ]
      }
    ]
  };
  el.value = [
    {
      "host": "srv-01",
      "env": "prod"
    }
  ];
</script>

row_editor: 'dialog' lists the rows as a table, showing the first four columns, and edits one at a time in a modal. Save checks the row’s own fields; Cancel leaves the row as it was. A row with an error from the form is marked in the table. Rules on row fields do not run inside the dialog.

A column with options_from loads its options through <baht-form>, like a top-level field. Its options_deps name top-level fields, not columns of the same row.

NameTypeDefaultDescription
rowErrorsJSValidationError[][]Validation errors to show per row
rowStatesJSRecord<string, DerivedFieldState>{}Rule-derived states of the row sub-fields, keyed `key[i].sub` (spec 02 §2a). Absent = every sub-field visible with its descriptor defaults.
rowLookupJSRowLookup | nullnullSet by the host form: what makes a `reference` column searchable.
fieldJSFieldDescriptor—Descriptor with type "repeater" and fields[] (sub-descriptors; no nesting)
valueJSobject[]nullOne object per row, keyed by sub-field key
disabledbooleanfalse
readonlybooleanfalse
requiredbooleanfalse
show-optionalbooleanfalseAppend the localized "(optional)" marker to the label when not required (set by <baht-form show-optional>).
errorJSstring | nullnull
debouncenumber | undefined—Debounce for typed edits (ms); unset = BahtFieldBase.defaultDebounce.
EventdetailDescription
baht-input{ key, value: object[] }The whole array after any row edit, add or remove
nameCustomEvent

A column with type: 'reference' works as it does on its own: it searches through registry.references, opens the table when the lookup has list, and read-only views show the record’s label. The lookup’s data is the form’s values with the column’s own row on top, so one column can depend on another in the same row.