I have a webpage with a useForm
hook implemented, featuring a multi-step form split into separate components.
Here's an example:
export default function create(){
const form = useForm({
name: '',
content: '',
is_published: 0,
some_more_fields_here
});
return (
<div>
<GeneralPageInformation form={form} />
<SeoInformation form={form} />
</div>
)
}
The form object returned by useForm
appears as follows:
InertiaFormProps<{name: string, content: string, is_published: number, rest of your fields}>
My attempt at defining this was:
interface IGeneralPageInformation {
form: InertiaFormProps;
}
Although giving access to properties like form.processting
and form.recentlySuccessful
,
the keys such as name
and content
were not visible when using functions like
form.setData('all available keys should show up here))
I could manually include the keys like so:
interface IGeneralPageInformation {
form: InertiaFormProps<{name: string, content: string, is_published: number, resf of the fields}>
}
However, this manual approach is not very "scalable" since every form would need editing whenever changes occur.