Oxform
API

createForm

Form configuration, values, status, validation, submission, and reset.

createForm

createForm(options) returns a stable CreateFormReturn<Values, Checks> with core form methods and reactive status getters. Values infer from schema; configured checks infer issue levels, with error always included. Options may be an object with getters or an accessor.

import { ,  } from '@oxform/solid';
import {  } from 'zod';

function () {
  const  = ({ : .({ : .() }), : { : '' } });
  const  = ({ , : 'email' });
  const  = .( => {
    .(.);
  });

  return (
    <
      ={ => {
        .();
        void ();
      }}
    >
      < ='Email' {....} />
      < ='submit' ={..}>
        Submit
      </>
    </>
  );
}

Options

OptionContract
schemaRequired Standard Schema validator. Infers values and supplies default submit validation.
defaultValuesRequired initial values and reset baseline. Creation does not validate them.
idOptional identifier, generated if omitted. Fixed after creation.
defaultStatusInitial overrides for dirty, submits, submitting, validating, and successful. Reset reapplies them.
defaultFieldStatusInitial dirty, touched, and blurred overrides by path; '*' supplies common defaults.
checksValidators keyed by issue level and event, with optional blocking flags.

Reactive updates change configuration for later operations. Updating defaults does not overwrite current values; call reset() to apply the new baseline.

Properties

PropertyContract
id, optionsIdentifier and current configuration.
valuesImperative current-values snapshot; use createSubscribe to observe it.
statusStable container with reactive status getters.
storeObservable store containing values, fields, and status.
fieldPath-based get, status, change, focus, blur, register, unregister, issues, setIssues, and reset.
arrayPath-based insert, append, prepend, swap, move, update, remove, and replace.

Path-based operations use the same contracts as bound fields and bound arrays, with the path as their first argument. form.field.register(name) returns an element callback.

validate(fields?, options?)

Returns Promise<[boolean, FormIssuesByLevel<Level>]>. Omit targets for whole-form validation, or supply a path or list of paths for their subtrees. Validators receive the full values object; targets limit returned issues and updated paths.

options.type selects change, blur, focus, or submit. Omitting it runs the root schema and all configured events. The boolean describes blocking issues emitted by this run; form.status.valid describes all current issues. See Validation.

const [valid, issues] = await form.validate('email', { type: 'blur' });
await form.validate();

submit(onSuccess, onError?)

Returns a zero-argument () => Promise<void> handler. Invoke that handler to submit. It runs whole-form submit validation, then awaits onSuccess(values, form) if both the run and aggregate current validity pass, or onError(issues, form) otherwise.

The handler marks the form dirty and submitting before validation. Normal completion increments submits, clears submitting, and records successful. A rejected validator or callback rejects the handler; these completion updates are not guaranteed after rejection. It does not prevent browser submission or suppress concurrent calls.

reset(options?)

Restores defaults, clears issues and refs, recreates fields, and resets submit status. It does not validate. values supplies a full values object for this reset without changing the default baseline; status overrides reset status.

Keep optionBehavior
issues: true or an array of levelsPreserve all issues or selected levels at retained paths.
refs: truePreserve registered elements at retained paths.
fields: truePreserve complete field state, including IDs, status, refs, and issues. Takes precedence over other field preservation flags.
form.reset();
form.reset({ keep: { refs: true, issues: ['error'] } });

Solid manages the internal mount and configuration-update calls. See Lifecycle for disposal and server rendering.

Types

Prop

Type

Prop

Type