Skip to content

Commit 232e38a

Browse files
committed
Fix multiple checkbox
1 parent 3dc0b5b commit 232e38a

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/mui-component-mapper/src/form-fields/multiple-choice-list.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FormControl from '@material-ui/core/FormControl';
1010
import FormHelperText from '@material-ui/core/FormHelperText';
1111

1212
import MultipleChoiceListCommon, { wrapperProps } from '@data-driven-forms/common/src/multiple-choice-list';
13+
import { validationError } from './helpers';
1314

1415
const FinalCheckbox = ({ isDisabled, label, ...props }) => (
1516
<FormControlLabel
@@ -28,17 +29,21 @@ FinalCheckbox.propTypes = {
2829
label: PropTypes.node,
2930
};
3031

31-
const Wrapper = ({ showError, label, error, children }) =>(
32-
<Grid container >
33-
<FormControl component="fieldset" >
34-
<FormLabel>{ label }</FormLabel>
35-
<FormGroup>
36-
{ children }
37-
</FormGroup>
38-
<FormHelperText>{ showError ? error : null }</FormHelperText>
39-
</FormControl>
40-
</Grid>
41-
);
32+
const Wrapper = ({ label, isRequired, children, meta, validateOnMount, helperText, description }) => {
33+
const invalid = validationError(meta, validateOnMount);
34+
35+
return (
36+
<Grid container>
37+
<FormControl required={ isRequired } error={ invalid } component="fieldset" >
38+
<FormLabel>{ label }</FormLabel>
39+
<FormGroup>
40+
{ children }
41+
</FormGroup>
42+
{ (invalid || helperText || description) && <FormHelperText>{ invalid || helperText || description }</FormHelperText> }
43+
</FormControl>
44+
</Grid>
45+
);
46+
};
4247

4348
Wrapper.propTypes = {
4449
...wrapperProps,

0 commit comments

Comments
 (0)