fix: association data not submitted when exposing association fields in subform/subTable (#6883)

This commit is contained in:
Katherine
2025-05-16 17:52:04 +08:00
committed by GitHub
parent fefd5916d4
commit fd87c8d38c
2 changed files with 8 additions and 4 deletions
@@ -107,7 +107,11 @@ function getFilteredFormValues(form) {
});
const readonlyPaths = _.uniq(
allFields
.filter((field) => field?.componentProps?.readOnlySubmit)
.filter((field) => {
const segments = field.path?.segments || [];
const path = segments.length <= 1 ? segments.join('.') : segments.slice(0, -1).join('.');
return field?.componentProps?.readOnlySubmit && !get(values, path)[field?.componentProps.filterTargetKey];
})
.map((field) => {
const segments = field.path?.segments || [];
if (segments.length <= 1) {
@@ -122,7 +126,6 @@ function getFilteredFormValues(form) {
_.unset(values, path);
}
});
return values;
}
@@ -29,7 +29,7 @@ import { isDisplayField } from '../utils';
*/
const useLazyLoadDisplayAssociationFieldsOfForm = () => {
const { name } = useCollection_deprecated();
const { getCollectionJoinField } = useCollectionManager_deprecated();
const { getCollectionJoinField, getCollection } = useCollectionManager_deprecated();
const form = useForm();
const fieldSchema = useFieldSchema();
const variables = useVariables();
@@ -90,7 +90,7 @@ const useLazyLoadDisplayAssociationFieldsOfForm = () => {
}
const { appends } = getAssociationAppends();
const collection = getCollection(collectionFieldRef.current?.collectionName);
variables
.parseVariable(variableString, formVariable, { appends })
.then(({ value }) => {
@@ -104,6 +104,7 @@ const useLazyLoadDisplayAssociationFieldsOfForm = () => {
field.componentProps = {
...field.componentProps,
readOnlySubmit: true,
filterTargetKey: collection?.filterTargetKey || 'id',
}; // 让它不参与提交
}
});