diff --git a/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx b/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx index 40daacd7f..7e0a5fa59 100644 --- a/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx +++ b/packages/client/src/collection-manager/Configuration/AddFieldAction.tsx @@ -7,6 +7,7 @@ import { cloneDeep } from 'lodash'; import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useRequest } from '../../api-client'; +import { useRecord } from '../../record-provider'; import { ActionContext, SchemaComponent, useCompile } from '../../schema-component'; import { useCreateAction } from '../action-hooks'; import { useCollectionManager } from '../hooks'; @@ -78,20 +79,25 @@ const useCreateCollectionField = () => { const form = useForm(); const { run } = useCreateAction(); const { refreshCM } = useCollectionManager(); + const { title } = useRecord(); return { async run() { await form.submit(); const options = form?.values?.uiSchema?.enum?.slice() || []; - form.setValuesIn( - 'uiSchema.enum', - options.map((option) => { - return { - value: uid(), - ...option, - }; - }), - ); - console.log('form.values', form.values); + if (options?.length) { + form.setValuesIn( + 'uiSchema.enum', + options.map((option) => { + return { + value: uid(), + ...option, + }; + }), + ); + } + if (form?.values?.interface === 'linkTo' && title) { + form.setValuesIn('reverseField.uiSchema.title', title); + } await run(); await refreshCM(); }, diff --git a/packages/client/src/collection-manager/interfaces/linkTo.ts b/packages/client/src/collection-manager/interfaces/linkTo.ts index abb11d186..000a87dfa 100644 --- a/packages/client/src/collection-manager/interfaces/linkTo.ts +++ b/packages/client/src/collection-manager/interfaces/linkTo.ts @@ -71,13 +71,13 @@ export const linkTo: IField = { 'x-decorator': 'FormItem', 'x-component': 'Select', }, - 'reverseField.uiSchema.title': { - type: 'string', - title: '{{t("Reverse field display name")}}', - required: true, - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, + // 'reverseField.uiSchema.title': { + // type: 'string', + // title: '{{t("Reverse field display name")}}', + // // required: true, + // 'x-decorator': 'FormItem', + // 'x-component': 'Input', + // }, // 'uiSchema.x-component-props.fieldNames.label': { // type: 'string', // title: '要显示的标题字段',