fix(association-field):submitting failed after adding data in subform for multiple association fields (#2065)
* fix: toManay sub-form add new data misalignment * fix: toManay sub-form add new submit failed * refactor: code improve * refactor: code improve
This commit is contained in:
parent
88d4af14df
commit
516fe408b9
@ -175,7 +175,7 @@ export const useCreateActionProps = () => {
|
|||||||
...overwriteValues,
|
...overwriteValues,
|
||||||
...assignedValues,
|
...assignedValues,
|
||||||
},
|
},
|
||||||
filterKeys:filterKeys,
|
filterKeys: filterKeys,
|
||||||
});
|
});
|
||||||
actionField.data.loading = false;
|
actionField.data.loading = false;
|
||||||
actionField.data.data = data;
|
actionField.data.data = data;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Field } from '@formily/core';
|
import { Field } from '@formily/core';
|
||||||
import { observer, useField, useFieldSchema, useForm } from '@formily/react';
|
import { observer, useField, useForm } from '@formily/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SchemaComponentOptions } from '../../';
|
import { SchemaComponentOptions } from '../../';
|
||||||
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
|
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
|
||||||
@ -17,7 +17,6 @@ const EditableAssociationField = observer(
|
|||||||
const { multiple } = props;
|
const { multiple } = props;
|
||||||
const field: Field = useField();
|
const field: Field = useField();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const fieldSchema = useFieldSchema();
|
|
||||||
const { options: collectionField, currentMode } = useAssociationFieldContext();
|
const { options: collectionField, currentMode } = useAssociationFieldContext();
|
||||||
|
|
||||||
const useCreateActionProps = () => {
|
const useCreateActionProps = () => {
|
||||||
|
@ -2,8 +2,9 @@ import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { ArrayField } from '@formily/core';
|
import { ArrayField } from '@formily/core';
|
||||||
import { spliceArrayState } from '@formily/core/esm/shared/internals';
|
import { spliceArrayState } from '@formily/core/esm/shared/internals';
|
||||||
import { RecursionField, observer, useFieldSchema } from '@formily/react';
|
import { observer, RecursionField, useFieldSchema } from '@formily/react';
|
||||||
import { action } from '@formily/reactive';
|
import { action } from '@formily/reactive';
|
||||||
|
import { each } from '@formily/shared';
|
||||||
import { Button, Card, Divider, Tooltip } from 'antd';
|
import { Button, Card, Divider, Tooltip } from 'antd';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -62,6 +63,12 @@ const ToManyNester = observer(
|
|||||||
insertCount: 1,
|
insertCount: 1,
|
||||||
});
|
});
|
||||||
field.value.splice(index + 1, 0, {});
|
field.value.splice(index + 1, 0, {});
|
||||||
|
|
||||||
|
each(field.form.fields, (field, key) => {
|
||||||
|
if (!field) {
|
||||||
|
delete field.form.fields[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
return field.onInput(field.value);
|
return field.onInput(field.value);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user