@@ -5,26 +5,23 @@ import { wrapperProps } from '@data-driven-forms/common/multiple-choice-list';
55import FormGroup from '../form-group' ;
66import { useFieldApi } from '@data-driven-forms/react-form-renderer' ;
77
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+ ) ;
1613
1714RadioOption . propTypes = {
1815 name : PropTypes . string . isRequired ,
1916 option : PropTypes . shape ( { label : PropTypes . string . isRequired , value : PropTypes . any . isRequired } ) . isRequired ,
2017} ;
2118
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+ } ) ;
2825
2926 return (
3027 < FormGroup
@@ -36,7 +33,7 @@ const Radio = ({ name, ...props }) => {
3633 FormItemProps = { FormItemProps }
3734 isRequired = { isRequired }
3835 >
39- < AntRadio . Group name = { name } disabled = { isDisabled || isReadOnly } { ...rest } >
36+ < AntRadio . Group name = { name } disabled = { isDisabled || isReadOnly } { ...input } { ... rest } >
4037 { options . map ( ( option ) => (
4138 < RadioOption key = { option . value } name = { name } option = { option } />
4239 ) ) }
@@ -58,6 +55,7 @@ Radio.propTypes = {
5855 isReadOnly : PropTypes . bool ,
5956 description : PropTypes . node ,
6057 FormItemProps : PropTypes . object ,
58+ component : PropTypes . string ,
6159} ;
6260
6361Radio . defaultProps = {
0 commit comments