Skip to content

Commit

Permalink
Merge pull request #6209 from WiXSL/fix-mutators
Browse files Browse the repository at this point in the history
Fix custom mutators crash SimpleForm and TabbedForm
  • Loading branch information
fzaninotto authored Apr 26, 2021
2 parents 5bdef88 + 4ccd6c4 commit 286ad03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/ra-core/src/form/FormWithRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const FormWithRedirect = ({
const redirect = useRef(props.redirect);
const onSave = useRef(save);
const formGroups = useRef<{ [key: string]: string[] }>({});
const finalMutators = useMemo(
() =>
mutators === defaultMutators
? mutators
: { ...defaultMutators, ...mutators },
[mutators]
);

// We don't use state here for two reasons:
// 1. There no way to execute code only after the state has been updated
Expand Down Expand Up @@ -162,7 +169,7 @@ const FormWithRedirect = ({
initialValues={finalInitialValues}
initialValuesEqual={initialValuesEqual}
keepDirtyOnReinitialize={keepDirtyOnReinitialize}
mutators={mutators} // necessary for ArrayInput
mutators={finalMutators} // necessary for ArrayInput
onSubmit={submit}
subscription={subscription} // don't redraw entire form each time one field changes
validate={validate}
Expand Down

0 comments on commit 286ad03

Please sign in to comment.