@@ -4,10 +4,21 @@ import Radio from '@material-ui/core/Radio';
4
4
import FormControlLabel from '@material-ui/core/FormControlLabel' ;
5
5
import FormControl from '@material-ui/core/FormControl' ;
6
6
import FormLabel from '@material-ui/core/FormLabel' ;
7
+ import FormHelperText from '@material-ui/core/FormHelperText' ;
8
+ import { wrapperProps } from '@data-driven-forms/common/src/multiple-choice-list' ;
7
9
8
- const RadioGroup = ( { FieldProvider, options, isDisabled, input, label } ) => (
10
+ const RadioGroup = ( {
11
+ FieldProvider,
12
+ options,
13
+ isDisabled,
14
+ input,
15
+ label,
16
+ isRequired,
17
+ helperText,
18
+ invalid,
19
+ } ) => (
9
20
< div className = "mui-ddform-radio-group" >
10
- < FormControl component = "fieldset" >
21
+ < FormControl required = { isRequired } error = { invalid } component = "fieldset" >
11
22
< FormLabel component = "legend" > { label } </ FormLabel >
12
23
{ options . map ( option => (
13
24
< FieldProvider
@@ -26,11 +37,13 @@ const RadioGroup = ({ FieldProvider, options, isDisabled, input, label }) => (
26
37
) }
27
38
/>
28
39
) ) }
40
+ { ( invalid || helperText ) && < FormHelperText > { invalid || helperText } </ FormHelperText > }
29
41
</ FormControl >
30
42
</ div >
31
43
) ;
32
44
33
45
RadioGroup . propTypes = {
46
+ ...wrapperProps ,
34
47
FieldProvider : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
35
48
options : PropTypes . arrayOf ( PropTypes . shape ( {
36
49
value : PropTypes . any ,
@@ -42,6 +55,7 @@ RadioGroup.propTypes = {
42
55
name : PropTypes . string . isRequired ,
43
56
onChange : PropTypes . func . isRequired ,
44
57
} ) ,
58
+ children : PropTypes . any ,
45
59
} ;
46
60
47
61
RadioGroup . defaultProps = {
0 commit comments