Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): revalidate nested fields on parent setFieldValue #2208

Openhemraj-007(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2208/headopened

Showing 4 changed files with 52 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
12 additions and 0 deletions.changeset/nested-field-revalidate.mdAdded
View file
@@ -0,0 +1,12 @@
+---
+'@tanstack/form-core': patch
+'@tanstack/react-form': patch
+'@tanstack/preact-form': patch
+'@tanstack/vue-form': patch
+'@tanstack/solid-form': patch
+'@tanstack/svelte-form': patch
+'@tanstack/angular-form': patch
+'@tanstack/lit-form': patch
+---
+​
+Revalidate mounted nested fields when a parent object field value is updated via `setFieldValue`. Fixes #2113.
11 additions and 0 deletionspackages/form-core/src/FormApi.tsModified
View file
@@ -2671,6 +2671,17 @@
if (!dontValidate) {
this.validateField(field, 'change')
+​
+ const fieldStr = field.toString()
+ for (const nestedField of Object.keys(this.fieldInfo)) {
+ if (
+ nestedField !== fieldStr &&
+ isFieldInGroup(fieldStr, nestedField) &&