mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: URL query parameter variables not working in public form field default values (#7084)
This commit is contained in:
parent
19d59c28fc
commit
2361f078eb
@ -19,6 +19,7 @@ import { useParentPopupVariableContext } from '../../schema-settings/VariableInp
|
||||
import { useCurrentParentRecordContext } from '../../schema-settings/VariableInput/hooks/useParentRecordVariable';
|
||||
import { usePopupVariableContext } from '../../schema-settings/VariableInput/hooks/usePopupVariable';
|
||||
import { useCurrentRecordContext } from '../../schema-settings/VariableInput/hooks/useRecordVariable';
|
||||
import { useURLSearchParamsVariable } from '../../schema-settings/VariableInput/hooks/useURLSearchParamsVariable';
|
||||
import { VariableOption } from '../types';
|
||||
import useContextVariable from './useContextVariable';
|
||||
|
||||
@ -52,6 +53,7 @@ const useLocalVariables = (props?: Props) => {
|
||||
dataSource: parentPopupDataSource,
|
||||
defaultValue: defaultValueOfParentPopupRecord,
|
||||
} = useParentPopupVariableContext();
|
||||
const { urlSearchParamsCtx, shouldDisplay: shouldDisplayURLSearchParams } = useURLSearchParamsVariable();
|
||||
const { datetimeCtx } = useDatetimeVariableContext();
|
||||
const { currentFormCtx } = useCurrentFormContext({ form: props?.currentForm });
|
||||
const { name: currentCollectionName } = useCollection_deprecated();
|
||||
@ -146,6 +148,10 @@ const useLocalVariables = (props?: Props) => {
|
||||
ctx: parentObjectCtx,
|
||||
collectionName: collectionNameOfParentObject,
|
||||
},
|
||||
shouldDisplayURLSearchParams && {
|
||||
name: '$nURLSearchParams',
|
||||
ctx: urlSearchParamsCtx,
|
||||
},
|
||||
] as VariableOption[]
|
||||
).filter(Boolean);
|
||||
}, [
|
||||
@ -170,6 +176,7 @@ const useLocalVariables = (props?: Props) => {
|
||||
parentObjectCtx,
|
||||
collectionNameOfParentObject,
|
||||
contextVariable,
|
||||
urlSearchParamsCtx,
|
||||
]); // 尽量保持返回的值不变,这样可以减少接口的请求次数,因为关系字段会缓存到变量的 ctx 中
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user