Skip to content

Commit

Permalink
Merge pull request #3123 from johncalvinroberts/master
Browse files Browse the repository at this point in the history
Fix undefined id in RadioButtonGroupInput
  • Loading branch information
Gildas Garcia committed Apr 13, 2019
2 parents bc45dbd + 14e72a0 commit 164e258
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/ra-ui-materialui/src/input/RadioButtonGroupInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,26 @@ export class RadioButtonGroupInput extends Component {

renderRadioButton = choice => {
const {
id,
optionText,
optionValue,
translate,
translateChoice,
source,
} = this.props;
const choiceName = React.isValidElement(optionText) // eslint-disable-line no-nested-ternary
? React.cloneElement(optionText, { record: choice })
: typeof optionText === 'function'
? optionText(choice)
: get(choice, optionText);

const nodeId = `${source}_${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)}`}
color="primary"
/>
}
control={<Radio id={nodeId} color="primary" />}
label={
translateChoice
? translate(choiceName, { _: choiceName })
Expand Down Expand Up @@ -173,7 +171,6 @@ RadioButtonGroupInput.propTypes = {
choices: PropTypes.arrayOf(PropTypes.object),
classes: PropTypes.object,
className: PropTypes.string,
id: PropTypes.string,
input: PropTypes.object,
isRequired: PropTypes.bool,
label: PropTypes.string,
Expand Down

0 comments on commit 164e258

Please sign in to comment.