Skip to content

Commit 57b7a1c

Browse files
committed
Fix switch
1 parent 6d7bfe1 commit 57b7a1c

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,23 @@ const selectComponent = ({
132132
{ ...rest }
133133
/>),
134134
[componentTypes.SWITCH]: () => (
135-
<FormGroup row>
136-
<FormControlLabel
137-
control={ <Switch
138-
{ ...rest }
139-
{ ...input }
140-
readOnly={ isReadOnly }
141-
disabled={ isDisabled || isReadOnly }
142-
checked={ !!input.value }
143-
onChange={ ({ target: { checked }}) => input.onChange(checked) }
144-
/> }
145-
label={ label }
146-
/>
147-
</FormGroup>),
135+
<FormControl required={ isRequired } error={ invalid } component="fieldset">
136+
<FormGroup>
137+
<FormControlLabel
138+
control={ <Switch
139+
{ ...rest }
140+
{ ...input }
141+
readOnly={ isReadOnly }
142+
disabled={ isDisabled || isReadOnly }
143+
checked={ !!input.value }
144+
onChange={ ({ target: { checked }}) => input.onChange(checked) }
145+
/> }
146+
label={ input.value ? onText || label : offText || label }
147+
/>
148+
{ (invalid || helperText) && <FormHelperText>{ invalid || helperText }</FormHelperText> }
149+
</FormGroup>
150+
</FormControl>
151+
),
148152
[componentTypes.DATE_PICKER]: () => (
149153
<MuiPickersUtilsProvider locale={ locale } utils={ MomentUtils }>
150154
<DatePicker

0 commit comments

Comments
 (0)