【发布时间】:2020-03-25 10:41:49
【问题描述】:
我创建了这个表单来生成一个动态反应页面,通过单选按钮选择选项。
在当前实例上,我能够选择所有指示的单选按钮,我希望在这些单选按钮中能够从所有生成的单选按钮中仅选择一个。
<Card className={classes.root} variant="outlined">
<CardContent>
<Container component="main" maxWidth="lg">
<CssBaseline />
<Grid container spacing={3}>
<Grid item xs={6} sm={1}></Grid>
<Grid item xs={12}>
<FormLabel component="legend">{values.question.text}</FormLabel>
<FormControl component="fieldset" key={uuid()}>
<RadioGroup name="groupSingleSelect" key={uuid()}>
{values.question.items.map(item => (
<React.Fragment key={uuid()}>
<FormControlLabel
label={item.name}
value="present"
control={
<Radio
id={item.id}
name={item.name}
checked={setSelectedRadioValue(
values.question.items,
item.id
)}
onChange={props.handleSingleRadioChange(item.id)}
/>
}
/>
</React.Fragment>
))}
</RadioGroup>
</FormControl>
</Grid>
<Grid item xs={6} sm={9}>
<Button
type="submit"
variant="contained"
color="primary"
onClick={continueToNextStep}
>
Continue
</Button>
</Grid>
</Grid>
</Container>
</CardContent>
</Card>
【问题讨论】:
标签: reactjs material-ui next.js