Compose forms with nested form structure #1200
-
The new createFormHook looks great but it appears that it only works when there's a shared data structure between the child and parent forms. The use case where this applies is when you have a section of a form that you want to make reusable. e.g. defaultValues: {
mailingAddress: {
addr1: "",
add2: "",
city: "",
},
billingAddress: {
addr1: "",
add2: "",
city: "",
}
} The only way I can think of to try to make this work currently would be with arrays but seems far from ideal and it breaks down even further depending where you render them on the screen. I think it would be great if somehow the parent form could 'scope' the child form to a specific part of the form state. I think this would make it possible to create truly reusable form components. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
This sounds like a case for a Then you could: <form.AppForm>
<form.AddressSubForm/>
</form.AppForm> |
Beta Was this translation helpful? Give feedback.
This sounds like a case for a
form.AppForm
component, not awithForm
component.Then you could: