form
API
function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
function form<TValue>(
model: WritableSignal<TValue>,
schemaOrOptions: FormOptions | SchemaOrSchemaFn<TValue>,
): Field<TValue>;
function form<TValue>(
model: WritableSignal<TValue>,
schema: SchemaOrSchemaFn<TValue>,
options: FormOptions,
): Field<TValue>;
function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
Creates a form wrapped around the given model data. A form is represented as simply a Field
of
the model data.
form
uses the given model as the source of truth and does not maintain its own copy of the
data. This means that updating the value on a FieldState
updates the originally passed in model
as well.
WritableSignal<TValue>
A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.
Field<TValue>
function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: FormOptions | SchemaOrSchemaFn<TValue>): Field<TValue>;
Creates a form wrapped around the given model data. A form is represented as simply a Field
of
the model data.
form
uses the given model as the source of truth and does not maintain its own copy of the
data. This means that updating the value on a FieldState
updates the originally passed in model
as well.
WritableSignal<TValue>
A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.
FormOptions | SchemaOrSchemaFn<TValue>
The second argument can be either
- A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.). When passing a schema, the form options can be passed as a third argument if needed.
- The form options
Field<TValue>
function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSchemaFn<TValue>, options: FormOptions): Field<TValue>;
Creates a form wrapped around the given model data. A form is represented as simply a Field
of
the model data.
form
uses the given model as the source of truth and does not maintain its own copy of the
data. This means that updating the value on a FieldState
updates the originally passed in model
as well.
WritableSignal<TValue>
A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.
SchemaOrSchemaFn<TValue>
A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.)
Field<TValue>