Skip to content

Commit 3dc0b5b

Browse files
committed
Fix single checkbox
1 parent 19abf43 commit 3dc0b5b

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/mui-component-mapper/src/form-fields/form-fields.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Grid from '@material-ui/core/Grid';
77
import MuiTextField from '@material-ui/core/TextField';
88
import Checkbox from '@material-ui/core/Checkbox';
99
import FormControlLabel from '@material-ui/core/FormControlLabel';
10+
import FormHelperText from '@material-ui/core/FormHelperText';
11+
import FormControl from '@material-ui/core/FormControl';
1012
import Switch from '@material-ui/core/Switch';
1113
import FormGroup from '@material-ui/core/FormGroup';
1214
import MuiSelect from './select-field';
@@ -39,6 +41,7 @@ const selectComponent = ({
3941
offText,
4042
error,
4143
locale = 'en',
44+
originalLabel,
4245
...rest
4346
}) => ({
4447
[componentTypes.TEXT_FIELD]: () => (
@@ -75,10 +78,20 @@ const selectComponent = ({
7578
/>
7679
),
7780
[componentTypes.CHECKBOX]: () => (
78-
<FormControlLabel
79-
control={ <Checkbox { ...input } disabled={ isDisabled } value={ input.name } /> }
80-
label={ label }
81-
/>
81+
<FormControl required={ isRequired } error={ invalid } component="fieldset">
82+
<FormGroup error={ invalid }>
83+
<FormControlLabel
84+
control={ <Checkbox
85+
{ ...input }
86+
disabled={ isDisabled || isReadOnly }
87+
value={ input.name }
88+
/> }
89+
disabled={ isDisabled || isReadOnly }
90+
label={ originalLabel }
91+
/>
92+
{ (invalid || helperText) && <FormHelperText>{ invalid || helperText }</FormHelperText> }
93+
</FormGroup>
94+
</FormControl>
8295
),
8396
[componentTypes.RADIO]: () => (
8497
<RadioGroup
@@ -183,6 +196,7 @@ const FinalFormField = ({
183196
invalid,
184197
label: invalid ? meta.error : label,
185198
helperText: helperText || description,
199+
originalLabel: label,
186200
})() }
187201
</Grid>
188202
);

0 commit comments

Comments
 (0)