Array subfield value not getting updated on `form` as I type
Hey everyone, I have a recipe form that has an array of ingredients. For each ingredient I am mapping and returning a nested ingredient form component and passing in the form as a prop. I have a toggle in this component to switch between view and edit mode. I want to disable the toggle to switch back to view mode if an ingredient has no name by accessing the form prop and grabbing the ingredient at that index to check the name. Im seeing the form input update, but value doesn't seem to update (line 97 of attached file). Is there any way you could take a look and see if Im missing something here?
https://github.com/tylerpashigian/t3-recipe-book/blob/feature/tanstack-react-form-migration/src/components/recipe/ingredient-form.tsx
Ideally I would like to get rid of the
isEmptyName
altogether, but because the form.getFieldValue("ingredients")?.[i]!.name
value isn't udpating I can't think of an alternative. If you wanna see where the form starts, you can check out recipe-form.tsx in the same folder. Please let me know if you need any clarifications, thanks!GitHub
t3-recipe-book/src/components/recipe/ingredient-form.tsx at feature...
Contribute to tylerpashigian/t3-recipe-book development by creating an account on GitHub.
2 Replies
molecular-blue•14mo ago
Basic Concepts and Terminology | TanStack Form React Docs
This page introduces the basic concepts and terminology used in the @tanstack/react-form library. Familiarizing yourself with these concepts will help you better understand and work with the library.
Form Options
exotic-emeraldOP•14mo ago
You're a life saver. Thank you!