(New to Inertia) Hi.
I have a fairly complex form. I think it's big enough to make it difficult to get an overview of the code if I'd put everything in the same component.
Also, several parts of the form use similar code to a large extent, f.ex having x fields for one row, like "name, email, subject" in one place, "id" in another, columns given by an array passed to that part of the form, and then you click the '+' button on the right to add another similar row below it.
name 1 email 1 subject 1 x
name 2 email 2 subject 2 x +
id 1 x
id 2 x
id 3 x +
But if I have the inertia form in the wrapper component and use sub components to build the form on the webpage, how to pass the form to those sub components without making them dependent on the form field names? Do I simply not pass the form to them, just data for the columns to be shown and then use f.ex the update event to save that data in the right place in the form in the root component?
const myForm = useForm(...)
</script>
<template>
<GenericTextInputGrid
:columns="[
{
field: "field1",
label: "Field 1",
},
{
...
}
]"
@update="<myForm.someField = $event.data>"
/>
</template>
...ish :-}? Would that be a good code structure for a form with sub components?