fix: update collection name handling in useCurrentFormVariable (#7125)

This commit is contained in:
Zeke Zhang 2025-07-01 10:01:50 +08:00 committed by GitHub
parent 026baab241
commit 22cd39552f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
import { useBlockContext } from '../../../block-provider'; import { useBlockContext } from '../../../block-provider';
import { useFormBlockContext } from '../../../block-provider/FormBlockProvider'; import { useFormBlockContext } from '../../../block-provider/FormBlockProvider';
import { CollectionFieldOptions_deprecated } from '../../../collection-manager'; import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
import { useDataBlockRequestData, useDataSource } from '../../../data-source'; import { useCollection, useDataSource } from '../../../data-source';
import { useFlag } from '../../../flag-provider/hooks/useFlag'; import { useFlag } from '../../../flag-provider/hooks/useFlag';
import { useBaseVariable } from './useBaseVariable'; import { useBaseVariable } from './useBaseVariable';
@ -100,6 +100,7 @@ export const useCurrentFormVariable = ({
const { currentFormCtx, shouldDisplayCurrentForm } = useCurrentFormContext({ form: _form }); const { currentFormCtx, shouldDisplayCurrentForm } = useCurrentFormContext({ form: _form });
const { t } = useTranslation(); const { t } = useTranslation();
const { collectionName } = useFormBlockContext(); const { collectionName } = useFormBlockContext();
const collection = useCollection();
const dataSource = useDataSource(); const dataSource = useDataSource();
const currentFormSettings = useBaseVariable({ const currentFormSettings = useBaseVariable({
collectionField, collectionField,
@ -108,7 +109,7 @@ export const useCurrentFormVariable = ({
maxDepth: 4, maxDepth: 4,
name: '$nForm', name: '$nForm',
title: t('Current form'), title: t('Current form'),
collectionName: collectionName, collectionName: collectionName || collection?.name,
noDisabled, noDisabled,
dataSource: dataSource?.key, dataSource: dataSource?.key,
returnFields: (fields, option) => { returnFields: (fields, option) => {