TanStack

T

TanStack

TanStack is a community of passionate software engineers striving for high-quality, open-source software for web devs

Join

react-query-questions

solid-query-questions

table-questions

virtual-questions

router-questions

react-charts-questions

ranger-questions

vue-query-questions

svelte-query-questions

bling-questions

form-questions

angular-query-questions

start-questions

db-questions

start-showcase

router-showcase

📣-announcements

other-emerald
other-emerald3/7/2025

Handling nested object validations

Hey there, im currently running into an issue with zod validations (more like a general issue). Im having a field like schema.output . output is like an object with different values object: { value: string, id: string} and i want to use the AppField object and then display the errors inside. But whenever im accessing the "top level", meaning output the errors are not there, because theyre happening on e.g. value with min(1). unless i dig into field.form.stateand extract the errors from there, i dont see any way to handle those "complex" forms. Its crucial for me, because im running into many scenarios where i need to validate an object rather than one field from the object, since theyre quite complex objects. cheers and thanks in advance 🙂...
conscious-sapphire
conscious-sapphire3/6/2025

Philosophy w/ respect to design systems

I saw this statement in the #form chat history:
We do not want you to use form.Field in normal app code, but instead wrap it into your codebase in a design system
Why is this desirable, is it still the stance of the library? Not all inputs are form inputs; the value/onChange may just need to derive from normal state. I'm also not sure I want to tie my design system components to one particular form library. Curious to hear more context!...
adverse-sapphire
adverse-sapphire3/6/2025

Duplicate Errors when using same Schema for onChange and onMount validation

Hello! I'm trying to run the same validation onMount and onChange: ``` const simpleFormSchema = z.object({ firstName: z.string().min(4, "must be longer than 4 characters"), lastName: z.string().min(4, "must be longer than 4 characters"),...
conscious-sapphire
conscious-sapphire3/6/2025

Use form Composition in solid js

Is there a way to use the form composition APIs in solid js yet? The feature doesn't seem to be mentioned in the solid docs + the APIs are not exported from the package that I can see. I think Tanstack Form seems really amazing! The composition seems like the true killer feature of this library and I would really love to use it in Solid 💙...
manual-pink
manual-pink3/6/2025

Cant getFieldValue(array[idx]) ?

https://stackblitz.com/edit/vitejs-vite-25mr55we?file=src%2Fcomponents%2FForm.tsx See the type error on row 46, ? Why can't do I get a type error when trying to grab an object out of an array like this? Accessing specific rows in tables is VERY common when I've used RHF at my jobs. ...
fascinating-indigo
fascinating-indigo3/4/2025

Form Composition - withForm - TypeScript error

Hello! I apologise in advance for the length of this message. I am in the process of updating my applications to TanStack Form v1 and testing to fully understand the new features/APIs. Having seen that it is now possible to split up large forms using withForm (which is great), I decided to do a relatively simple test. Unfortunately, I am encountering a TypeScript error. So I would like to see if anyone knows if this is due to a problem of understanding on my part, or a potential bug that could be fixed....
correct-apricot
correct-apricot3/4/2025

How to derive values to preserve form state integrity

I have two dropdown in my form, categories and movies. If I select a category, some movie, and then change the category, the movie value should reset to the first option of the new movie list. Otherwise, the form would keep a movie value that doesn't belong to the selected category. If I had to design such API, I would something like Saphyra does with reducer:...
deep-jade
deep-jade3/4/2025

Basic validation example

Having a frustrating time with the new 1.0.0 and basic validation. Maybe the documentation is not updated? I JUST want to do this: - when user submits form - validate against zod schema...
grumpy-cyan
grumpy-cyan3/3/2025

Relaunch validation even if there is already an error, and reset validation of certain fields

Hello, I have a form with checkboxes and 2 date fields. Date fields are required only if the third checkbox is checked (this checkbox can be selected only if you choose the item 3 in the select). The first problem is when I select the item 3 without value in the input at the right and validate the form there is an error, it's ok. But when I check the third checkbox, date fields are now required but if I submit, the error is not displayed because there is already an error on the input field. Is it possible to revalidate all the form on submit even if there is already an error ? ...
foreign-sapphire
foreign-sapphire2/28/2025

Get fieldMeta from array element

Is there a way to getFieldMeta from an index element and not a subField? For example if I have people[] and need to see if people[i] has any changes within it, there doesn't seem to be meta associated with that. I either have the entire people array isDirty or I can see specific subFields like people[i].name is dirty, but no way to check if a particular element has any changes?...
automatic-azure
automatic-azure2/27/2025

onSubmit callback does not get invoked - React Native

Hi! Im trying to use tanstack form with react-native (expo). So far, validation works, but the onSubmit callback never gets called This is how my code looks like. I would expect to see the console.logs inside of onSubmit, but instead I only see "SUBMITTING FORM" and thats it. I dont know if i am doing something incredibly stupid that I am not seeing or what, but I cant get this to work ```bash...
ambitious-aqua
ambitious-aqua2/26/2025

How do I type my form if I need to pass it to other components?

Before in 0.40 I was doing: ```ts form: ReturnType<typeof useForm<DocumentFormData>...
deep-jade
deep-jade2/26/2025

v.45.1 and type errors

I'm trying to update from 42.1 and it's blowing up with new requirements Generic type 'ReactFormExtendedApi' requires 10 type argument(s). Where I've been passing just 1 argument without problem. ...
No description
adverse-sapphire
adverse-sapphire2/26/2025

Getting all errors from field AND subfield

I have three subfields I would like to have a list of errors from. I noticed that there isn't a convenient way to do that, which either means I have to manually call <form>#getFieldMeta() on all subpaths, or get all errors and reduce them based on my parent field's name. Is there an easier way? Example of my implementation:...
eastern-cyan
eastern-cyan2/25/2025

should blur trigger onChange validation?

Hey there, appreciate the library, was doing some form work and noticed I'm getting onChange validation errors when clicking into and then out of a field (but without changing the value). Looking at the code it seems like if a field was never previously touched, then blurring the field causes the "change" validation to run. Does this seem accurate? Did I miss something in the docs re: this behavior? https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L1602...
manual-pink
manual-pink2/24/2025

field.state.meta.errors type is undefined[] when using Form level schema only?

https://stackblitz.com/edit/vitejs-vite-4fblmacv?file=src%2Fcomponents%2FForm.tsx You can see the highlighted type error for errors? Not sure if this should be inferred from a generic? I notice that if I use a field level validator, the type is updated....
manual-pink
manual-pink2/23/2025

Can't use Zod/Yup schema for form level validator?

On 0.43.2, when I try to use a Yup or Zod schema at form level, I get a type error for validators.onChange? https://stackblitz.com/edit/vitejs-vite-bnbraktt?file=src%2Fcomponents%2FForm.tsx What's the appropriate way to use Yup/Zod now? Dont think we need validatorAdapter anymore....
ambitious-aqua
ambitious-aqua2/21/2025

Is this a bug with removeValue on nested array elements?

Hey all, I thought I should ask here before posting the issue in the repo just in case. I have a made a minimal example which is attached but I'm not sure if its a bug or if I'm doing something wrong. I am trying to remove an object from a nested array. This is the schema ```tsx...
genetic-orange
genetic-orange2/21/2025

Equivalent to setError?

Hi. I am using react-hook-form now, and my foel has recaptcha. I am keeping track of recaptcha in the form state, like any other input. I was using setValue() to set the value in the form state after the widget has been clicked and setError() when the server was returning an error related to recatpcha. Using TanStack Form, I replaced setValue() with setFieldValue() but I do not know how to replace setError(). Any tips? tahnk you 🙂
foreign-sapphire
foreign-sapphire2/20/2025

"has been changed since submission" state?

Is there a way to have a state like "changed since last submission" on the entire form. Ideally the analogs for dirty/touched. I've tried building this myself to no avail, and it doesn't seem like it's available in the API. Thanks!...