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

Fix undefined id in RadioButtonGroupInput #3123

Merged
merged 2 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ Lastly, use the `options` attribute if you want to override any of Material UI's
labelPosition: 'right'
}} />
```
**Note**: The `RadioButtonGroupInput` component accepts an optional `id` prop. It is recommended to use this prop if you have more than one `RadioButtonGroupInput` field on one form to avoid interference between the form controls.
{% endraw %}

Refer to [Material UI RadioGroup documentation](http://www.material-ui.com/#/components/radio-button) for more details.
Expand Down
5 changes: 3 additions & 2 deletions packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ export class RadioButtonGroupInput extends Component {
: typeof optionText === 'function'
? optionText(choice)
: get(choice, optionText);
const nodeId = id ? `${id}_${get(choice, optionValue)}` : get(choice, optionValue)
return (
<FormControlLabel
htmlFor={`${id}_${get(choice, optionValue)}`}
htmlFor={nodeId}
key={get(choice, optionValue)}
value={get(choice, optionValue)}
control={
<Radio
id={`${id}_${get(choice, optionValue)}`}
id={nodeId}
color="primary"
/>
}
Expand Down