This commit is contained in:
katherinehhh 2024-02-07 17:03:44 +08:00
parent 8fb099f5b6
commit 899031e239

View File

@ -74,9 +74,12 @@ export const CollectionFieldInternalFieldV2: React.FC = (props: Props) => {
const targetCollection = getCollection(collectionField?.target); const targetCollection = getCollection(collectionField?.target);
let fieldNames = {}; let fieldNames = {};
if (collectionField?.target && targetCollection) { if (collectionField?.target && targetCollection) {
const initField = collectionField?.targetKey || targetCollection.getPrimaryKey();
fieldNames = { fieldNames = {
label: collectionField?.targetKey || targetCollection.getPrimaryKey(), label: targetCollection.getFields()?.find((v) => v.name === field.componentProps.fieldNames?.label)
value: collectionField?.targetKey || targetCollection.getPrimaryKey(), ? field.componentProps.fieldNames?.label
: initField,
value: initField,
}; };
} }
const componentProps = merge(originalProps, { ...(field.componentProps || {}), fieldNames }); const componentProps = merge(originalProps, { ...(field.componentProps || {}), fieldNames });