From 899031e2396ae29900a4d886a686efa32d521ef1 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Wed, 7 Feb 2024 17:03:44 +0800 Subject: [PATCH] fix: bug --- .../src/data-source/collection-field/CollectionField.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/data-source/collection-field/CollectionField.tsx b/packages/core/client/src/data-source/collection-field/CollectionField.tsx index d220e2fb57..719ba77bf1 100644 --- a/packages/core/client/src/data-source/collection-field/CollectionField.tsx +++ b/packages/core/client/src/data-source/collection-field/CollectionField.tsx @@ -74,9 +74,12 @@ export const CollectionFieldInternalFieldV2: React.FC = (props: Props) => { const targetCollection = getCollection(collectionField?.target); let fieldNames = {}; if (collectionField?.target && targetCollection) { + const initField = collectionField?.targetKey || targetCollection.getPrimaryKey(); fieldNames = { - label: collectionField?.targetKey || targetCollection.getPrimaryKey(), - value: collectionField?.targetKey || targetCollection.getPrimaryKey(), + label: targetCollection.getFields()?.find((v) => v.name === field.componentProps.fieldNames?.label) + ? field.componentProps.fieldNames?.label + : initField, + value: initField, }; } const componentProps = merge(originalProps, { ...(field.componentProps || {}), fieldNames });