You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I like to split my forms into separate components that group related and reusable sets of inputs. For example, in my database I have independent record for "Entity" which controls it's top-level settings and "EntityRevision", which controls the data which is updated in a versioned manner. When I create entity for the first time, I want to create a form that will encompass fields both for "Entity" and first "EntityRevision" in it's history. But when user edits the entity, I want to create separate form for creating new revision that will only have controls for the data that changes from version to version.
Describe the solution you'd like
I create components for two groups of entities:
interfaceEntityFormData{entityData: string}interfaceRevisionFormData{revisionData: string}exportfunctionEntityFormBody({ form }: {form: UseFormReturn<EntityFormData>}){/*...*/}exportfunctionRevisionFormBody({ form }: {form: UseFormReturn<RevisionFormData>}){/*...*/}
And then use the library to create a shared form that will get passed to both components:
export function RevisionFormBody({ form }: { form: UseFormReturn });
Unfortunately, currently I get this type error:
Type 'UseFormReturn<EntityFormData|RevisionFormData,any,undefined>' is not assignable to type 'UseFormReturn<EntityFormData>'. The types returned by 'watch()' are incompatible between these types. Type 'EntityFormData|RevisionFormData' is not assignable to type 'EntityFormData'. Type 'RevisionFormData' is not assignable to type 'EntityFormData'.
However, when I cast it manually, everything works. I haven't investigated this issue in depth, but I suspect that either all usages of these entities should be comparable, or at least a large enough subset. In my case, I just use Controller component to extract data about particular fields.
Describe alternatives you've considered
For now, I write the same code, but just use casts to solve this problem.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I like to split my forms into separate components that group related and reusable sets of inputs. For example, in my database I have independent record for "Entity" which controls it's top-level settings and "EntityRevision", which controls the data which is updated in a versioned manner. When I create entity for the first time, I want to create a form that will encompass fields both for "Entity" and first "EntityRevision" in it's history. But when user edits the entity, I want to create separate form for creating new revision that will only have controls for the data that changes from version to version.
Describe the solution you'd like
I create components for two groups of entities:
And then use the library to create a shared form that will get passed to both components:
export function RevisionFormBody({ form }: { form: UseFormReturn });
Unfortunately, currently I get this type error:
However, when I cast it manually, everything works. I haven't investigated this issue in depth, but I suspect that either all usages of these entities should be comparable, or at least a large enough subset. In my case, I just use
Controller
component to extract data about particular fields.Describe alternatives you've considered
For now, I write the same code, but just use casts to solve this problem.
The text was updated successfully, but these errors were encountered: