Wit Form
Patterns

Imperative Updates

Fill fields from code: load a saved address, look up a city from a ZIP code, copy one address into another, or clear one.

Billing address

Try 10001, 94103 or 60601

Shipping address

Try 10001, 94103 or 60601

What this shows

useFormContext() lets any component inside the form read and write it.

  • setValue(name, { value }) sets one field and re-validates it, as in the ZIP code lookup.
  • setFieldValues([...]) sets several fields at once, as in the saved address and the Clear button.
  • getValue({ name, type: 'field' }) reads a field, as in Copy from billing.

On this page