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
This commit is contained in:
katherinehhh 2023-10-19 22:56:04 +08:00 committed by GitHub
parent e05a30380a
commit 0be4e6d94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}`,