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.
Example
Section titled “Example”<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}/>Properties
Section titled “Properties”component?
Section titled “component?”
optionalcomponent: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.
computed()?
Section titled “computed()?”
optionalcomputed: (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.
Parameters
Section titled “Parameters”values
Section titled “values”Record<string, unknown>
Returns
Section titled “Returns”unknown
Example
Section titled “Example”fields: { totalCalories: { computed: (values) => values.ingredients.reduce( (sum, ing) => sum + (ing.calories * ing.amount) / 100, 0, ), readOnly: true, },}default?
Section titled “default?”
optionaldefault:unknown
Defined in: packages/forms/src/types.ts:136
Default value for the field in create mode.
hidden?
Section titled “hidden?”
optionalhidden: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.
label?
Section titled “label?”
optionallabel:string
Defined in: packages/forms/src/types.ts:130
Override the auto-generated label for this field.
placeholder?
Section titled “placeholder?”
optionalplaceholder:string
Defined in: packages/forms/src/types.ts:132
Placeholder text shown inside the input.
readOnly?
Section titled “readOnly?”
optionalreadOnly: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.
validate()?
Section titled “validate()?”
optionalvalidate: (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.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”string | undefined