Skip to content

docs(react): add Getting and Setting Form Values guide#2077

Open
mixelburg wants to merge 1 commit intoTanStack:mainfrom
mixelburg:docs/getting-and-setting-field-values
Open

docs(react): add Getting and Setting Form Values guide#2077
mixelburg wants to merge 1 commit intoTanStack:mainfrom
mixelburg:docs/getting-and-setting-field-values

Conversation

@mixelburg
Copy link

Summary

Adds a new guide page (React) covering the frequently-asked question of how to read and write form values in TanStack Form.

Closes #478

What's included

The guide walks through all the scenarios raised in the issue:

Topic What the guide covers
Initializing the form defaultValues (static & shared via formOptions)
Async / API values Plain fetch + state pattern; TanStack Query (links to existing async-initial-values guide)
Reading values reactively useStore, form.Subscribe (links to Reactivity guide)
Reading values imperatively form.getFieldValue(), form.state.values
Setting a single field form.setFieldValue(), field.setValue() / field.handleChange()
Setting all fields at once form.reset(newValues)
Validation when setting programmatically Runs by default; can suppress with { dontValidate: true }; manual trigger via form.validateField()
Marking a field as touched field.setMeta() alongside the value update
Listening for changes Snippet + link to the Listeners guide

The guide is also added to the navigation in docs/config.json right after "Basic Concepts".

Checklist

  • Docs only change (no source code touched)
  • All code snippets are consistent with existing guides (same import style, same naming conventions)
  • Added entry in docs/config.json under the React Guides section

Adds a new guide page that covers:
- Initializing forms with static and async/API-fetched values (with and without TanStack Query)
- Reading field values reactively (useStore, form.Subscribe) and imperatively (getFieldValue, form.state.values)
- Setting field values programmatically (setFieldValue, field.setValue, form.reset)
- Validation behaviour when setting values programmatically, and how to suppress or trigger it manually
- Marking fields as touched alongside programmatic updates
- Brief overview of the listeners API for side-effect-driven value changes, with links to the Reactivity and Listeners guides

Closes TanStack#478
@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

⚠️ No Changeset found

Latest commit: c65a7f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Guide page about getting and setting field values

1 participant