Skip to content
Source
Sign inSign up
TanStack/form

feat(form-core): [v2] restore replaceValue on array fields #2419

MergedMFA-G(GitHub profile, opens in a new tab)merged 2 commits intoalpha fromrefs/pull/2419/headmerged by LeCarbonator(GitHub profile, opens in a new tab)

Showing 13 changed files with 25 additions and 0 deletions (loading 10).

x
0 of 13 viewed, 13 left
6 additions and 0 deletions.changeset/brave-lists-replace.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/form-core': minor
+'@tanstack/vue-form': minor
+---
+​
+Restore `field.replaceValue()` and add `form.replaceFieldValue()` for replacing an array element in place
6 additions and 0 deletionsdocs/arrays.mdModified
View file
@@ -379,6 +379,9 @@
// Remove the item at an index.
field.removeValue(index)
​
+// Replace the item at an index.
+field.replaceValue(index, value)
+​
// Exchange two items.
field.swapValues(indexA, indexB)
​
@@ -402,6 +405,9 @@
// Remove the item at an index.
form.removeFieldValue('items', index)
​
+// Replace the item at an index.
+form.replaceFieldValue('items', index, value)
+​
// Exchange two items.
form.swapFieldValues('items', indexA, indexB)
​