fix: association block was not associated after adding data (#2907)

This commit is contained in:
katherinehhh 2023-10-26 16:41:38 +08:00 committed by GitHub
parent 568b12a537
commit 108453f90c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,7 @@ const useResource = (props: UseResourceProps) => {
const { fieldSchema } = useActionContext();
const isCreateAction = fieldSchema?.['x-action'] === 'create';
const association = useAssociation(props);
console.log(association);
const sourceId = useSourceId?.();
const field = useField();
const withoutTableFieldResource = useContext(WithoutTableFieldResource);
@ -96,6 +97,9 @@ const useResource = (props: UseResourceProps) => {
if (record[association?.sourceKey || 'id']) {
return api.resource(resource, record[association?.sourceKey || 'id']);
}
if (record?.__parent?.[association?.sourceKey || 'id']) {
return api.resource(resource, record.__parent[association?.sourceKey || 'id']);
}
return api.resource(collection);
};