-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SaveButton transform options not working as expected #9889
Comments
The Please provide a reproduction for the issue you report. And by the way, we wrote an issue template so that we have enough details to investigate. You saw that template when you created a new issue. If you don't follow it, we'll close the issue. |
What you were expecting: It isn't specified in the documentation transform option is available only for SaveButton with type button What happened instead:
Steps to reproduce:
Related code: Other information: Environment
|
Indeed this seems like a documentation issue. Thanks for the report. |
According to the documentation
https://marmelab.com/react-admin/SaveButton.html#transform
a SaveButton with the default type "submit" should be able to use a transform callback to transform the data before sending it.
<SaveButton transform={transformUser} />
In reality trying to use this property only result on a warning and no data transformation, which is confirmed by the the source code
warning( type === 'submit' && ((mutationOptions && (mutationOptions.onSuccess || mutationOptions.onError)) || transform), 'Cannot use <SaveButton mutationOptions> props on a button of type "submit". To override the default mutation options on a particular save button, set the <SaveButton type="button"> prop, or set mutationOptions in the main view component (<Create> or <Edit>).' );
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/button/SaveButton.tsx
I think either the code or the documentation should be updated
The text was updated successfully, but these errors were encountered: