Skip to content

Commit

Permalink
Merge pull request #4544 from agent3bood/patch-1
Browse files Browse the repository at this point in the history
Fix Edit Toolbar docs to explain how to use a CreateButton
  • Loading branch information
fzaninotto authored Mar 24, 2020
2 parents 90d579a + 4519b1d commit 026b989
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/CreateEdit.md
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,27 @@ Here are the props received by the `Toolbar` component when passed as the `toolb
**Tip**: To alter the form values before submitting, you should use the `handleSubmit` prop. See [Altering the Form Values before Submitting](#altering-the-form-values-before-submitting) for more information and examples.
**Tip**: If you want to include a `<CreateButton>` in the `<Toolbar>`, the props injected by `<Toolbar>` to its children (`handleSubmit`, `handleSubmitWithRedirect`, `onSave`, `invalid`, `pristine`, `saving`, and `submitOnEnter`) will cause React warnings. You'll need to wrap `<CreateButton>` in another component and ignore the injected props, as follows:
```jsx
const ToolbarCreateButton = ({
handleSubmit,
handleSubmitWithRedirect,
onSave,
invalid,
pristine,
saving,
submitOnEnter,
...rest
}) => <CreateButton {...rest} />;

const PostEditToolbar = props => (
<Toolbar {...props} >
<ToolbarCreateButton />
</Toolbar>
);
```
## Customizing The Form Layout
You can customize each row in a `<SimpleForm>` or in a `<TabbedForm>` by passing props to the Input components:
Expand Down

0 comments on commit 026b989

Please sign in to comment.