Skip to content

createAutoForm

createAutoForm(plugin): (__namedParameters) => Element

Defined in: packages/forms/src/auto-form.tsx:74

Create an AutoForm React component bound to a specific UI FormPlugin.

The returned component introspects a Drizzle table via introspectTable, builds validation via createResolver, and renders fields using the plugin’s components. Supports both create and edit modes, per-field overrides via FieldConfig, column exclusion, and external react-hook-form instances.

FormPlugin

A FormPlugin providing the UI components for rendering.

A React component (AutoForm) that accepts AutoFormProps.

(__namedParameters): Element

AutoFormProps

Element

import { createAutoForm, createFormPlugin } from "@cfast/forms";
const plugin = createFormPlugin({ components: joyComponents });
const AutoForm = createAutoForm(plugin);
// Create mode
<AutoForm table={posts} mode="create" onSubmit={handleSubmit} />
// Edit mode with field overrides
<AutoForm
table={posts}
mode="edit"
data={existingPost}
fields={{ title: { label: "Post Title" } }}
exclude={["createdAt"]}
onSubmit={handleSubmit}
/>