File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { Admin , Resource } from 'react-admin' ;
3
- import { PostList , PostEdit } from './posts' ;
3
+ import { PostList , PostEdit , PostCreate } from './posts' ;
4
4
import { UserList } from './users' ;
5
5
import jsonServerProvider from 'ra-data-json-server' ;
6
6
7
7
const dataProvider = jsonServerProvider ( 'http://jsonplaceholder.typicode.com' ) ;
8
8
const App = ( ) => (
9
9
< Admin dataProvider = { dataProvider } >
10
10
< Resource name = "users" list = { UserList } />
11
- < Resource name = "posts" list = { PostList } edit = { PostEdit } />
11
+ < Resource name = "posts" list = { PostList } edit = { PostEdit } create = { PostCreate } />
12
12
</ Admin >
13
13
) ;
14
14
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ import { List,
8
8
SimpleForm ,
9
9
ReferenceInput ,
10
10
SelectInput ,
11
- TextInput
11
+ TextInput ,
12
+ Create
12
13
} from 'react-admin' ;
13
14
14
15
export const PostList = props => (
@@ -36,3 +37,15 @@ export const PostEdit = props => (
36
37
</ SimpleForm >
37
38
</ Edit >
38
39
) ;
40
+
41
+ export const PostCreate = props => (
42
+ < Create { ...props } >
43
+ < SimpleForm >
44
+ < ReferenceInput source = "userId" reference = "users" >
45
+ < SelectInput optionText = "name" />
46
+ </ ReferenceInput >
47
+ < TextInput source = "title" />
48
+ < TextInput multiline source = "body" />
49
+ </ SimpleForm >
50
+ </ Create >
51
+ ) ;
You can’t perform that action at this time.
0 commit comments