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,
|
||||
...assignedValues,
|
||||
},
|
||||
filterKeys:filterKeys,
|
||||
filterKeys: filterKeys,
|
||||
});
|
||||
actionField.data.loading = false;
|
||||
actionField.data.data = data;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 { SchemaComponentOptions } from '../../';
|
||||
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
|
||||
@ -17,7 +17,6 @@ const EditableAssociationField = observer(
|
||||
const { multiple } = props;
|
||||
const field: Field = useField();
|
||||
const form = useForm();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { options: collectionField, currentMode } = useAssociationFieldContext();
|
||||
|
||||
const useCreateActionProps = () => {
|
||||
|
@ -2,8 +2,9 @@ import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { css } from '@emotion/css';
|
||||
import { ArrayField } from '@formily/core';
|
||||
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 { each } from '@formily/shared';
|
||||
import { Button, Card, Divider, Tooltip } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -62,6 +63,12 @@ const ToManyNester = observer(
|
||||
insertCount: 1,
|
||||
});
|
||||
field.value.splice(index + 1, 0, {});
|
||||
|
||||
each(field.form.fields, (field, key) => {
|
||||
if (!field) {
|
||||
delete field.form.fields[key];
|
||||
}
|
||||
});
|
||||
return field.onInput(field.value);
|
||||
});
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user