Skip to content

FieldConfig

FieldConfig = object

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

Per-field overrides for customizing auto-generated form fields.

Pass a record of { [columnName]: FieldConfig } to the AutoForm fields prop to override labels, placeholders, visibility, defaults, components, or validation for individual fields.

<AutoForm
table={posts}
mode="create"
fields={{
title: { label: "Post Title", placeholder: "Enter a title..." },
content: { component: RichTextEditor },
authorId: { hidden: true, default: currentUser.id },
}}
onSubmit={handleSubmit}
/>

optional component: React.ComponentType<FieldComponentProps>

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

Custom React component to render instead of the plugin’s default for this input type.


optional computed: (values) => unknown

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

Compute this field’s value from the rest of the form values. The function is re-evaluated whenever any watched form value changes, and the result is written back into the form via setValue so it shows up in the rendered input and the submitted payload.

Computed fields are typically combined with readOnly: true.

Record<string, unknown>

unknown

fields: {
totalCalories: {
computed: (values) =>
values.ingredients.reduce(
(sum, ing) => sum + (ing.calories * ing.amount) / 100,
0,
),
readOnly: true,
},
}

optional default: unknown

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

Default value for the field in create mode.


optional hidden: boolean

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

Hide this field from the rendered form. The field is still submitted if a default is set.


optional label: string

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

Override the auto-generated label for this field.


optional placeholder: string

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

Placeholder text shown inside the input.


optional readOnly: boolean

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

Mark the field as read-only. Read-only fields are still rendered and submitted but cannot be edited by the user. Pairs naturally with computed.


optional validate: (value) => string | undefined

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

Custom validation function. Return an error message string to fail, or undefined to pass.

unknown

string | undefined