Skip to content

Commit 7b91acc

Browse files
committed
Fixing a problem preventing the Radios to load values correctly
1 parent a1d709d commit 7b91acc

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-autoform-bootstrap-ui",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Bootstrap UI implementation for redux-autoform",
55
"main": "./lib/index.js",
66
"scripts": {

src/components/fieldComponents/Radio.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ class Radio extends Component {
88
onChange(event.target.value);
99
};
1010

11-
getOptions = () => {
11+
getOptions = (value) => {
1212
let { options, name, fieldLayout } = this.props;
13-
let radioProps = { inline: fieldLayout == 'inline', name };
13+
14+
// these props don't vary per item
15+
let invariantRadioProps = { inline: fieldLayout == 'inline', name, onChange: this.handleChange };
1416

1517
return options.map((item, index) => (
16-
<BootstrapRadio key={index} value={item.value} onChange={this.handleChange} {...radioProps}>
18+
<BootstrapRadio key={index} value={item.value} checked={item.value == value} {...invariantRadioProps}>
1719
{item.text}
1820
</BootstrapRadio>
1921
))
2022
};
2123

2224
render() {
23-
let { error, touched, displayName, name, help, fieldLayout, innerSize } = this.props;
25+
let { error, touched, displayName, name, help, fieldLayout, innerSize, value } = this.props;
2426
let formGroupProps = { error, touched, displayName, name, help, fieldLayout, innerSize };
25-
let options = this.getOptions();
27+
let options = this.getOptions(value);
2628

2729
return (
2830
<FormGroup {...formGroupProps} >

0 commit comments

Comments
 (0)