Skip to content

NestedTableConfig

NestedTableConfig<TTable, TAs> = object

Defined in: packages/forms/src/types.ts:260

Configuration for a nested child table rendered as a dynamic field array under an AutoForm.

This is the successor to the deprecated ChildTableConfig record shape. Pass an array of these via the AutoForm nested prop:

<AutoForm
table={recipes}
nested={[
{
table: ingredients,
foreignKey: "recipeId",
min: 1,
max: 50,
reorderable: true,
fields: { name: { placeholder: "Flour" } },
},
]}
onSubmit={async (values) => {
// values.ingredients is fully typed — no casts needed.
}}
/>

The array shape (as opposed to Record<string, ChildTableConfig>) avoids the JSX-reserved children attribute collision and enables the whole form value type to be inferred via InferAutoFormValues.

The key the nested array appears under in the submitted values is either:

  • as (explicit override), or
  • the table’s runtime name from getTableName(table) (e.g. sqliteTable("ingredients", ...)ingredients).

TTable extends Table = SQLiteTable

TAs extends string | undefined = string | undefined

optional addLabel: string

Defined in: packages/forms/src/types.ts:293

Override the “Add row” button label.


optional as: TAs

Defined in: packages/forms/src/types.ts:279

Override the key the nested array appears under in submitted form values.

Defaults to the table’s runtime name (e.g. sqliteTable("ingredients", …)"ingredients"). Pass as when two nested tables would otherwise collide, or when you want the form key to differ from the table name.


optional exclude: keyof InferTableRow<TTable> & string[]

Defined in: packages/forms/src/types.ts:289

Additional column names to omit from the rendered nested rows.


optional fields: Partial<Record<keyof InferTableRow<TTable> & string, FieldConfig>>

Defined in: packages/forms/src/types.ts:287

Per-column overrides for the nested table fields, identical in shape to the parent FieldConfig.


foreignKey: keyof InferTableRow<TTable> & string

Defined in: packages/forms/src/types.ts:271

Foreign key column on the nested table that points back at the parent. The column is automatically excluded from the rendered nested fields and stamped onto each row at submit time.


optional label: string

Defined in: packages/forms/src/types.ts:291

Override the heading rendered above the nested table (defaults to a humanised key).


optional max: number

Defined in: packages/forms/src/types.ts:283

Maximum number of rows the user is allowed to add. Defaults to unlimited.


optional min: number

Defined in: packages/forms/src/types.ts:281

Minimum number of rows the user must provide. Defaults to 0.


optional reorderable: boolean

Defined in: packages/forms/src/types.ts:285

Show reorder controls (move up / move down). Defaults to false.


table: TTable

Defined in: packages/forms/src/types.ts:265

The Drizzle SQLite table that backs each row of the array.