File tree 2 files changed +16
-3
lines changed
packages/ra-core/src/form
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
Title ,
15
15
minLength ,
16
16
} from 'react-admin' ; // eslint-disable-line import/no-unresolved
17
+ import { useDataProvider } from 'ra-core' ;
17
18
18
19
const LinkToRelatedPost = ( { record } ) => (
19
20
< Link to = { `/posts/${ record . post_id } ` } >
@@ -50,7 +51,18 @@ const CommentEdit = props => {
50
51
save,
51
52
basePath,
52
53
version,
53
- } = useEditController ( props ) ;
54
+ } = useEditController ( { ...props , undoable : false } ) ;
55
+
56
+ const dataProvider = useDataProvider ( ) ;
57
+
58
+ async function mySave ( values ) {
59
+ const results = await dataProvider . update ( resource , values ) ;
60
+ if ( values . body . startsWith ( 'invalid' ) ) {
61
+ return {
62
+ body : 'dont like it' ,
63
+ } ;
64
+ }
65
+ }
54
66
return (
55
67
< div className = "edit-page" >
56
68
< Title defaultTitle = { `Comment #${ record ? record . id : '' } ` } />
@@ -70,7 +82,7 @@ const CommentEdit = props => {
70
82
redirect = { redirect }
71
83
resource = { resource }
72
84
record = { record }
73
- save = { save }
85
+ save = { mySave }
74
86
version = { version }
75
87
>
76
88
< TextInput disabled source = "id" fullWidth />
Original file line number Diff line number Diff line change @@ -98,7 +98,8 @@ const FormWithRedirect: FC<FormWithRedirectOwnProps & FormProps> = ({
98
98
: redirect . current ;
99
99
const finalValues = sanitizeEmptyValues ( finalInitialValues , values ) ;
100
100
101
- onSave . current ( finalValues , finalRedirect ) ;
101
+ const result = onSave . current ( finalValues , finalRedirect ) ;
102
+ return result ;
102
103
} ;
103
104
104
105
return (
You can’t perform that action at this time.
0 commit comments