@@ -5,26 +5,23 @@ import { wrapperProps } from '@data-driven-forms/common/multiple-choice-list';
5
5
import FormGroup from '../form-group' ;
6
6
import { useFieldApi } from '@data-driven-forms/react-form-renderer' ;
7
7
8
- const RadioOption = ( { name, option, ...rest } ) => {
9
- const { input } = useFieldApi ( { name, type : 'radio' , value : option . value } ) ;
10
- return (
11
- < AntRadio key = { `${ name } -${ option . value } ` } { ...input } id = { `${ name } -${ option . value } ` } { ...rest } >
12
- { option . label }
13
- </ AntRadio >
14
- ) ;
15
- } ;
8
+ const RadioOption = ( { name, option : { label, value, ...rest } } ) => (
9
+ < AntRadio key = { `${ name } -${ value } ` } id = { `${ name } -${ value } ` } value = { value } { ...rest } >
10
+ { label }
11
+ </ AntRadio >
12
+ ) ;
16
13
17
14
RadioOption . propTypes = {
18
15
name : PropTypes . string . isRequired ,
19
16
option : PropTypes . shape ( { label : PropTypes . string . isRequired , value : PropTypes . any . isRequired } ) . isRequired ,
20
17
} ;
21
18
22
- const Radio = ( { name, ...props } ) => {
23
- const { options, isDisabled, label, isRequired, helperText, description, isReadOnly, meta, validateOnMount, FormItemProps, ...rest } = useFieldApi ( {
24
- ... props ,
25
- name ,
26
- type : 'radio' ,
27
- } ) ;
19
+ const Radio = ( { name, component , ...props } ) => {
20
+ const { options, isDisabled, label, isRequired, helperText, description, isReadOnly, meta, validateOnMount, FormItemProps, input , ...rest } =
21
+ useFieldApi ( {
22
+ ... props ,
23
+ name ,
24
+ } ) ;
28
25
29
26
return (
30
27
< FormGroup
@@ -36,7 +33,7 @@ const Radio = ({ name, ...props }) => {
36
33
FormItemProps = { FormItemProps }
37
34
isRequired = { isRequired }
38
35
>
39
- < AntRadio . Group name = { name } disabled = { isDisabled || isReadOnly } { ...rest } >
36
+ < AntRadio . Group name = { name } disabled = { isDisabled || isReadOnly } { ...input } { ... rest } >
40
37
{ options . map ( ( option ) => (
41
38
< RadioOption key = { option . value } name = { name } option = { option } />
42
39
) ) }
@@ -58,6 +55,7 @@ Radio.propTypes = {
58
55
isReadOnly : PropTypes . bool ,
59
56
description : PropTypes . node ,
60
57
FormItemProps : PropTypes . object ,
58
+ component : PropTypes . string ,
61
59
} ;
62
60
63
61
Radio . defaultProps = {
0 commit comments