From 457afe3e060904a7b1f4e6c5c0e54e3f85814a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rairn?= <958414905@qq.com> Date: Thu, 15 Jun 2023 23:26:04 +0800 Subject: [PATCH] fix: avoid error (#2060) --- .../src/schema-component/antd/form-item/FormItem.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx index 9433af29d..6e519a207 100644 --- a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx @@ -100,6 +100,7 @@ export const FormItem: any = observer( ); FormItem.Designer = function Designer() { + let targetField; const { getCollectionFields, getInterface, getCollectionJoinField, getCollection } = useCollectionManager(); const { getField } = useCollection(); const { form } = useFormBlockContext(); @@ -112,9 +113,11 @@ FormItem.Designer = function Designer() { const IsShowMultipleSwitch = useIsShowMultipleSwitch(); const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); - const targetField = getCollectionJoinField( - `${collectionField?.target}.${fieldSchema['x-component-props'].fieldNames?.label}`, - ); + if (collectionField?.target) { + targetField = getCollectionJoinField( + `${collectionField.target}.${fieldSchema['x-component-props']?.fieldNames?.label || 'id'}`, + ); + } const targetCollection = getCollection(collectionField?.target); const interfaceConfig = getInterface(collectionField?.interface);