From 0be4e6d94d8ab73a6473af3976ad65f5140016e1 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Thu, 19 Oct 2023 22:56:04 +0800 Subject: [PATCH] fix: select field incorrect rendering in association field block (#2876) * fix: select field incorrect rendering in assoction field block * fix: select field incorrect rendering in assoction field block --- packages/core/client/src/schema-initializer/utils.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/schema-initializer/utils.ts b/packages/core/client/src/schema-initializer/utils.ts index 46343e5a4..b0d21e5be 100644 --- a/packages/core/client/src/schema-initializer/utils.ts +++ b/packages/core/client/src/schema-initializer/utils.ts @@ -406,6 +406,7 @@ export const useAssociatedFormItemInitializerFields = (options?: any) => { ?.map((subField) => { const interfaceConfig = getInterface(subField.interface); const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file'; + const isAssociationField = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany'].includes(subField?.type); const schema = { type: 'string', name: `${field.name}.${subField.name}`, @@ -415,10 +416,12 @@ export const useAssociatedFormItemInitializerFields = (options?: any) => { 'x-read-pretty': readPretty, 'x-component-props': { 'pattern-disable': block === 'Form' && readPretty, - fieldNames: { - label: isFileCollection ? 'preview' : 'id', - value: 'id', - }, + fieldNames: isAssociationField + ? { + label: isFileCollection ? 'preview' : 'id', + value: 'id', + } + : undefined, }, 'x-decorator': 'FormItem', 'x-collection-field': `${name}.${field.name}.${subField.name}`,