TanStackT
TanStack2mo ago
3 replies
primary-violet

Form that is standalone AND used as subform

I have kind of an insane task where I have 5 different types of forms, calling them F1 - F5
- F1, F2, F3, F4 share many fields, so I am using the same form hook and validation schema for them
- F5 is the new form I need to create. It is also similar to the other forms, but it needs to contain an arbitrary number of F1-F4 forms as "subforms".

The data handling is stumping me, I've been playing around with either:
- Making the "subforms" actual separate forms that alter the value of the parent form on submit
- Using withForm to make the "subforms", but it seems like this is mostly designed just for breaking up a form into a few smaller chunks

I'd like to reuse the same fields and validations as much as possible so I don't have multiple copies of complicated form logic, but any guidance is appreciated!
Was this page helpful?