Skip to content
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

Ids for radio inputs when using react element for choices is set incorrectly #4924

Closed
helenwilliamson opened this issue Jun 9, 2020 · 2 comments · Fixed by #4928
Closed

Comments

@helenwilliamson
Copy link
Contributor

What you were expecting:
When creating a RadioButtonGroupInput using a react element for the choices, I expect that the rendered inputs will have unique ids

What happened instead:
Instead the rendered inputs will end up with the same id

Steps to reproduce:
Create RadioButtonGroupInput as per https://marmelab.com/react-admin/Inputs.html#radiobuttongroupinput using a React element:

const choices = [
   { id: 123, first_name: 'Leo', last_name: 'Tolstoi' },
   { id: 456, first_name: 'Jane', last_name: 'Austen' },
];
const FullNameField = ({ record }) => <span>{record.first_name} {record.last_name}</span>;
<RadioButtonGroupInput source="gender" choices={choices} optionText={<FullNameField />}/>

Check ids for radio inputs in rendered html. They're all gender_[object Object]

Proposed fix:
Change

to the following:

const nodeId = `${source}_${value}`;
@djhi
Copy link
Collaborator

djhi commented Jun 10, 2020

Hi and thanks for the report. Would you mind openning a pull request with the proposed fix?

@helenwilliamson
Copy link
Contributor Author

done - #4928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants