Skip to content

SaveButton transform options not working as expected #9889

Closed
@jeromediaz

Description

@jeromediaz

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions