diff --git a/packages/ra-core/src/controller/useEditController.ts b/packages/ra-core/src/controller/useEditController.ts index 0fda10c7bca..842d105b398 100644 --- a/packages/ra-core/src/controller/useEditController.ts +++ b/packages/ra-core/src/controller/useEditController.ts @@ -92,12 +92,12 @@ const useEditController = (props: EditProps): EditControllerProps => { ); const save = useCallback( - (data: Partial, redirectTo = 'list') => + (data: Partial, redirectTo = 'list', { onSuccess, onFailure } = {}) => update( { payload: { data } }, { action: CRUD_UPDATE, - onSuccess: () => { + onSuccess: onSuccess ? onSuccess : () => { notify( successMessage || 'ra.notification.updated', 'info', @@ -108,7 +108,7 @@ const useEditController = (props: EditProps): EditControllerProps => { ); redirect(redirectTo, basePath, data.id, data); }, - onFailure: error => + onFailure: onFailure ? onFailure : error => notify( typeof error === 'string' ? error