stormy-gold
stormy-gold12mo ago

I have been trying to ask the ai/support bot how to assign an error message when using the supabase

I have been trying to ask the ai/support bot how to assign an error message when using the supabase dataprovider and not having any luck. Basically I am using the Supabase dataprovider, I have a form that has a field called slug, the server will throw an error if it is a duplicate, I want the async form validation to have a friendly description attached to the field. Right now this is what I have
const { modalProps, formProps, onFinish, close, form } = useModalForm<any>({
action: "create",
resource: "sites",
defaultVisible: true,
redirect: false,
mutationMode: "pessimistic",
defaultFormValues: {
is_active: true,
},
createMutationOptions:{

onError: async (error: HttpError, variables, context) => {
console.error(error);

form.setFields([
{
name: 'slug',
errors: ['Slug error' ],
},
]);

// Handle other errors if needed
return Promise.reject(error);
}
}
});
const { modalProps, formProps, onFinish, close, form } = useModalForm<any>({
action: "create",
resource: "sites",
defaultVisible: true,
redirect: false,
mutationMode: "pessimistic",
defaultFormValues: {
is_active: true,
},
createMutationOptions:{

onError: async (error: HttpError, variables, context) => {
console.error(error);

form.setFields([
{
name: 'slug',
errors: ['Slug error' ],
},
]);

// Handle other errors if needed
return Promise.reject(error);
}
}
});
I have tried variations of this, is the only option to create a custom data provider and handle it in the create? Is there no overrides in the supabase data provider for this kind of handling?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?