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
Clear and concise description of the problem
Considering the following scenario :
when I want to create an updateSchema :
itineraryForm.vehicleis an objet of type Vehicle. But in my case I would like to have hisid.I have try with pass
defaultValuesto 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
Alternative
No response
Additional context
No response
Validations