Skip to content

Commit

Permalink
Fix simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Dec 7, 2020
1 parent 1a83090 commit 963a37b
Showing 1 changed file with 58 additions and 53 deletions.
111 changes: 58 additions & 53 deletions examples/simple/src/comments/CommentEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AutocompleteInput,
DateInput,
EditActions,
EditContextProvider,
useEditController,
Link,
ReferenceInput,
Expand Down Expand Up @@ -43,71 +44,75 @@ const inputText = record => `${record.title} - ${record.id}`;

const CommentEdit = props => {
const classes = useEditStyles();
const controllerProps = useEditController(props);
const {
resource,
record,
redirect,
save,
basePath,
version,
} = useEditController(props);
} = controllerProps;
return (
<div className="edit-page">
<Title defaultTitle={`Comment #${record ? record.id : ''}`} />
<div className={classes.actions}>
<EditActions
basePath={basePath}
resource={resource}
data={record}
hasShow
hasList
/>
</div>
<Card className={classes.card}>
{record && (
<SimpleForm
<EditContextProvider value={controllerProps}>
<div className="edit-page">
<Title defaultTitle={`Comment #${record ? record.id : ''}`} />
<div className={classes.actions}>
<EditActions
basePath={basePath}
redirect={redirect}
resource={resource}
record={record}
save={save}
version={version}
>
<TextInput disabled source="id" fullWidth />
<ReferenceInput
source="post_id"
reference="posts"
perPage={15}
sort={{ field: 'title', order: 'ASC' }}
fullWidth
data={record}
hasShow
hasList
/>
</div>
<Card className={classes.card}>
{record && (
<SimpleForm
basePath={basePath}
redirect={redirect}
resource={resource}
record={record}
save={save}
version={version}
>
<AutocompleteInput
matchSuggestion={(filterValue, suggestion) =>
true
}
optionText={<OptionRenderer />}
inputText={inputText}
options={{ fullWidth: true }}
/>
</ReferenceInput>
<TextInput disabled source="id" fullWidth />
<ReferenceInput
source="post_id"
reference="posts"
perPage={15}
sort={{ field: 'title', order: 'ASC' }}
fullWidth
>
<AutocompleteInput
matchSuggestion={(
filterValue,
suggestion
) => true}
optionText={<OptionRenderer />}
inputText={inputText}
options={{ fullWidth: true }}
/>
</ReferenceInput>

<LinkToRelatedPost />
<TextInput
source="author.name"
validate={minLength(10)}
fullWidth
/>
<DateInput source="created_at" fullWidth />
<TextInput
source="body"
validate={minLength(10)}
fullWidth={true}
multiline={true}
/>
</SimpleForm>
)}
</Card>
</div>
<LinkToRelatedPost />
<TextInput
source="author.name"
validate={minLength(10)}
fullWidth
/>
<DateInput source="created_at" fullWidth />
<TextInput
source="body"
validate={minLength(10)}
fullWidth={true}
multiline={true}
/>
</SimpleForm>
)}
</Card>
</div>
</EditContextProvider>
);
};

Expand Down

0 comments on commit 963a37b

Please sign in to comment.