Skip to content

Commit ebc9267

Browse files
committed
Customize PostEdit with disabled id field, name for user reference field and long text input for editing body field
1 parent b860db4 commit ebc9267

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Roll our own PostEdit component, using EditGuesser suggestions
1+
// Customize PostEdit with disabled id field, name for user reference field and long text input for editing body field
22
// https://marmelab.com/react-admin/Tutorial.html
33

44
/*

src/posts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { List, Datagrid, TextField, ReferenceField, EditButton, Edit, SimpleForm, ReferenceInput, SelectInput, TextInput } from 'react-admin';
2+
import { List, Datagrid, TextField, ReferenceField, EditButton, Edit, SimpleForm, ReferenceInput, SelectInput, TextInput, DisabledInput, LongTextInput } from 'react-admin';
33

44
export const PostList = props => (
55
<List {...props}>
@@ -17,12 +17,12 @@ export const PostList = props => (
1717
export const PostEdit = props => (
1818
<Edit {...props}>
1919
<SimpleForm>
20+
<DisabledInput source="id" />
2021
<ReferenceInput source="userId" reference="users">
21-
<SelectInput optionText="id" />
22+
<SelectInput optionText="name" />
2223
</ReferenceInput>
23-
<TextInput source="id" />
2424
<TextInput source="title" />
25-
<TextInput source="body" />
25+
<LongTextInput source="body" />
2626
</SimpleForm>
2727
</Edit>
2828
)

0 commit comments

Comments
 (0)