fix: avoid error (#2060)

This commit is contained in:
被雨水过滤的空气-Rairn 2023-06-15 23:26:04 +08:00 committed by GitHub
parent d0632d73fd
commit 457afe3e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,6 +100,7 @@ export const FormItem: any = observer(
); );
FormItem.Designer = function Designer() { FormItem.Designer = function Designer() {
let targetField;
const { getCollectionFields, getInterface, getCollectionJoinField, getCollection } = useCollectionManager(); const { getCollectionFields, getInterface, getCollectionJoinField, getCollection } = useCollectionManager();
const { getField } = useCollection(); const { getField } = useCollection();
const { form } = useFormBlockContext(); const { form } = useFormBlockContext();
@ -112,9 +113,11 @@ FormItem.Designer = function Designer() {
const IsShowMultipleSwitch = useIsShowMultipleSwitch(); const IsShowMultipleSwitch = useIsShowMultipleSwitch();
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']); const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
const targetField = getCollectionJoinField( if (collectionField?.target) {
`${collectionField?.target}.${fieldSchema['x-component-props'].fieldNames?.label}`, targetField = getCollectionJoinField(
`${collectionField.target}.${fieldSchema['x-component-props']?.fieldNames?.label || 'id'}`,
); );
}
const targetCollection = getCollection(collectionField?.target); const targetCollection = getCollection(collectionField?.target);
const interfaceConfig = getInterface(collectionField?.interface); const interfaceConfig = getInterface(collectionField?.interface);