-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
Description
Clear and concise description of the problem
Considering the following scenario :
export interface Vehicle {
id: number
name: string
}
export interface Itinerary {
id: number
vehicle: Vehicle
label: string
}const updateFormSchema = z.object({
vehicle: z.number(),
label: z.string()
})
export default defineItemType<Itinerary>().model({
name: 'itineraries',
formSchema: {
update: updateFormSchema
}
})when I want to create an updateSchema :
const itineraryForm = await store.itineraries.updateForm(props.id)itineraryForm.vehicle is an objet of type Vehicle. But in my case I would like to have his id.
I have try with pass defaultValues to overrides this, but it don't work.
Suggested solution
We can imagine to pass the data to the defaultValues function to map model within the form
const itineraryForm = await store.itineraries.updateForm(props.id, {
defaultValues: (item) => ({
...item,
vehicle: item.vehicle.id
}
})Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.