Skip to content

Commit 05dd246

Browse files
committed
fix(ant): pass name to Form.Item
1 parent d1c1e58 commit 05dd246

File tree

10 files changed

+16
-2
lines changed

10 files changed

+16
-2
lines changed

packages/ant-component-mapper/src/date-picker/date-picker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const DatePicker = (props) => {
1919
description={description}
2020
FormItemProps={FormItemProps}
2121
isRequired={isRequired}
22+
input={input}
2223
>
2324
<AntDatePicker
2425
disabled={isDisabled || isReadOnly}

packages/ant-component-mapper/src/dual-list-select/dual-list-select.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const DualListSelect = (props) => {
2929
description={description}
3030
FormItemProps={FormItemProps}
3131
isRequired={isRequired}
32+
input={input}
3233
>
3334
<Transfer
3435
{...input}

packages/ant-component-mapper/src/form-group/form-group.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Form } from 'antd';
55
import { validationError } from '../validation-error/';
66
import { childrenPropTypes } from '@data-driven-forms/common/prop-types-templates';
77

8-
const FormGroup = ({ label, children, isRequired, FormItemProps, meta, validateOnMount, helperText, description, hideLabel }) => {
8+
const FormGroup = ({ label, children, isRequired, FormItemProps, meta, validateOnMount, helperText, description, hideLabel, input }) => {
99
const invalid = validationError(meta, validateOnMount);
1010
const warning = (meta.touched || validateOnMount) && meta.warning;
1111
const help = invalid || warning || helperText || description;
@@ -16,6 +16,7 @@ const FormGroup = ({ label, children, isRequired, FormItemProps, meta, validateO
1616
help={help}
1717
label={!hideLabel && label}
1818
required={isRequired}
19+
name={input?.name}
1920
{...FormItemProps}
2021
>
2122
{children}
@@ -35,6 +36,7 @@ FormGroup.propTypes = {
3536
helperText: PropTypes.node,
3637
description: PropTypes.node,
3738
hideLabel: PropTypes.bool,
39+
input: PropTypes.object,
3840
};
3941

4042
export default FormGroup;

packages/ant-component-mapper/src/multiple-choice-list/multiple-choice-list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FinalCheckbox.propTypes = {
1616
label: PropTypes.node,
1717
};
1818

19-
const Wrapper = ({ label, isRequired, children, meta, validateOnMount, helperText, description, FormItemProps }) => (
19+
const Wrapper = ({ label, isRequired, children, meta, input, validateOnMount, helperText, description, FormItemProps }) => (
2020
<FormGroup
2121
label={label}
2222
meta={meta}
@@ -25,6 +25,7 @@ const Wrapper = ({ label, isRequired, children, meta, validateOnMount, helperTex
2525
description={description}
2626
FormItemProps={FormItemProps}
2727
isRequired={isRequired}
28+
input={input}
2829
>
2930
{children}
3031
</FormGroup>

packages/ant-component-mapper/src/select/select.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const Select = (props) => {
3838
description={description}
3939
FormItemProps={FormItemProps}
4040
isRequired={isRequired}
41+
input={input}
4142
>
4243
<AntSelect
4344
{...input}

packages/ant-component-mapper/src/switch/switch.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const Switch = (props) => {
3434
description={description}
3535
FormItemProps={FormItemProps}
3636
isRequired={isRequired}
37+
input={input}
3738
>
3839
<AntSwitch
3940
{...rest}

packages/ant-component-mapper/src/tests/components.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ describe('formFields generated tests', () => {
7575
}
7676

7777
expect(screen.getByText(field.label)).toBeInTheDocument();
78+
79+
if (![componentTypes.RADIO, componentTypes.SLIDER].includes(component)) {
80+
expect(screen.getByLabelText(field.label)).toBeInTheDocument();
81+
}
7882
});
7983

8084
it('renders with error', async () => {

packages/ant-component-mapper/src/text-field/text-field.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const TextField = (props) => {
1818
description={description}
1919
FormItemProps={FormItemProps}
2020
isRequired={isRequired}
21+
input={input}
2122
>
2223
<Input
2324
{...input}

packages/ant-component-mapper/src/textarea/textarea.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const Textarea = (props) => {
2020
description={description}
2121
FormItemProps={FormItemProps}
2222
isRequired={isRequired}
23+
input={input}
2324
>
2425
<TextArea
2526
{...input}

packages/ant-component-mapper/src/time-picker/time-picker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const TimePicker = (props) => {
1919
description={description}
2020
FormItemProps={FormItemProps}
2121
isRequired={isRequired}
22+
input={input}
2223
>
2324
<AntTimePicker
2425
use12Hours={true}

0 commit comments

Comments
 (0)