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 9433af29d6..6e519a2078 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);