diff --git a/packages/core/client/src/schema-settings/LinkageRules/index.tsx b/packages/core/client/src/schema-settings/LinkageRules/index.tsx index 03acb9eca3..5fbc3b7bf4 100644 --- a/packages/core/client/src/schema-settings/LinkageRules/index.tsx +++ b/packages/core/client/src/schema-settings/LinkageRules/index.tsx @@ -20,6 +20,7 @@ import { SubFormProvider } from '../../schema-component/antd/association-field/h import { DynamicComponentProps } from '../../schema-component/antd/filter/DynamicComponent'; import { FilterContext } from '../../schema-component/antd/filter/context'; import { VariableInput, getShouldChange } from '../VariableInput/VariableInput'; +import { useCurrentFormContext } from '../VariableInput/hooks/useFormVariable'; import { LinkageRuleActionGroup } from './LinkageRuleActionGroup'; import { EnableLinkage } from './components/EnableLinkage'; import { ArrayCollapse } from './components/LinkageHeader'; @@ -95,6 +96,7 @@ export const FormLinkageRules = withDynamicSchemaProps( const { name } = useCollection_deprecated(); const { getAllCollectionsInheritChain } = useCollectionManager_deprecated(); const parentRecordData = useCollectionParentRecordData(); + const { shouldDisplayCurrentForm } = useCurrentFormContext(); const variableKey = getActiveContextName(localVariables); const components = useMemo(() => ({ ArrayCollapse }), []); const schema = useMemo( @@ -103,7 +105,7 @@ export const FormLinkageRules = withDynamicSchemaProps( properties: { rules: { type: 'array', - default: transformDefaultValue(defaultValues, variableKey), + default: transformDefaultValue(defaultValues, shouldDisplayCurrentForm ? variableKey : '$nRecord'), 'x-component': 'ArrayCollapse', 'x-decorator': 'FormItem', 'x-component-props': {