ilokesto

CreateForm

CreateForm<TValues> is the core class behind every adapter. Construct it with CreateFormOptions: initialValues, optional form-level schema, optional schemaOptions, and optional validateOn. The instance implements Form<TValues>, so adapters and tests can rely on one stable contract.

const form = new CreateForm({
  initialValues: { email: '', profile: { name: '' } },
  schema: profileSchema,
  schemaOptions: { libraryOptions: { abortEarly: false } },
  validateOn: ['change', 'blur', 'submit'],
});

const unsubscribe = form.subscribe(() => {
  console.log(form.getState().submitCount);
});

Use getState() when you need the immutable snapshot, and subscribe() when a framework or external observer needs notification. Prefer getValue, getValues, setValue, and getFieldState for field-level operations. focus() is an intent command; the current core state shape does not store a focused flag.

Practical guidance

Keep this page near the source when you build abstractions. The reference describes what the package exposes, while guides show one way to compose those pieces. If a helper hides FieldPathInput, validation triggers, or array rebasing, document that helper with the same precision so future maintainers know whether strings, tuples, or stable keys are expected.

On this page