equal-aqua
equal-aqua2y ago

Edit page doesn't fetch and populate the form fields.

I have multi-level menu and from that menu I have and list page and edit action on list of item. But when I go to edit page the page doesn't fetch the data and populate the form field. I am confused with how the edit view work on antd. This is my edit page code:
export const ScheduleEdit: React.FC<IResourceComponentsProps> = () => {
const t = useTranslate();
const {
saveButtonProps,
formProps,
} = useForm<ISchedule>({
resource: 'bo/schedules',
});

return (
<Edit
saveButtonProps={saveButtonProps}
title="Edit Schedule"
>

// form fields

</Edit>
)
}
export const ScheduleEdit: React.FC<IResourceComponentsProps> = () => {
const t = useTranslate();
const {
saveButtonProps,
formProps,
} = useForm<ISchedule>({
resource: 'bo/schedules',
});

return (
<Edit
saveButtonProps={saveButtonProps}
title="Edit Schedule"
>

// form fields

</Edit>
)
}
4 Replies
optimistic-gold
optimistic-gold2y ago
Hey @dipbazz, when you pass an explicit resource, it also requires id field to be passed to the useForm
equal-aqua
equal-aqua2y ago
Hey @aliemirs. Thanks for your response. My bad
optimistic-gold
optimistic-gold2y ago
This is done to avoid showing wrong data. In such cases like you have multiple API calls made in a page and they have different resource properties, we're not using the id from the URL because it can be the wrong id for that resource 🤔 Hope this clears the logic here 🙏
equal-aqua
equal-aqua2y ago
Yup that clears my doubt and concern. Thanks for your quick response.