React-admin: Camelcase in source props of <Input> components changes json attribute when creating form.

Created on 10 Feb 2020  路  4Comments  路  Source: marmelab/react-admin

Hi, I am not sure whether I should report this under bug or make it a proposed feature...

What you were expecting:

When doing a create operation on database, I expected that the source props of components determine the json attribute. For example,

<FormTab label="resources.choices.tabs.details" path="details">
    <NumberInput 
      source="priceRange"
    />
</FormTab>

I was expecting a json like this {priceRange: ...} to pass to backend when saving the form.

What happened instead:

the above produces a json like this {price_range: ...} when passed to the backend.

Thank you.

Most helpful comment

You are specifying them but it looks like your dataProvider is changing them. Please provide a codesandbox showing the issue or ask the question on Stackoverflow.

Yup, it's the data provider... thanks!

All 4 comments

This is most probably done by your dataProvider. The react-admin components do not transform the source.

This is most probably done by your dataProvider. The react-admin components do not transform the source.

I see, I thought I was specifying the attributes of the json I'm going to submit to the backend through the source, and react-admin transforms it from camelCase to snake_case, which is not what I wanted.

You are specifying them but it looks like your dataProvider is changing them. Please provide a codesandbox showing the issue or ask the question on Stackoverflow.

You are specifying them but it looks like your dataProvider is changing them. Please provide a codesandbox showing the issue or ask the question on Stackoverflow.

Yup, it's the data provider... thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alukito picture alukito  路  3Comments

Kmaschta picture Kmaschta  路  3Comments

rkyrychuk picture rkyrychuk  路  3Comments

marknelissen picture marknelissen  路  3Comments

samanmohamadi picture samanmohamadi  路  3Comments