From 4a346a41195531da7edc1bf3b3b73e0dac73bcf6 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Tue, 12 Mar 2024 09:30:38 +0800 Subject: [PATCH] fix: view collection association field foreignkey should be select (#3671) --- .../collection-manager/Configuration/components/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/components/index.tsx b/packages/core/client/src/collection-manager/Configuration/components/index.tsx index eb5e4404b..5e7a60e25 100644 --- a/packages/core/client/src/collection-manager/Configuration/components/index.tsx +++ b/packages/core/client/src/collection-manager/Configuration/components/index.tsx @@ -221,11 +221,11 @@ export const ForeignKey = observer( const { getCollection } = useCollectionManager_deprecated(); const record = useRecord(); const field: any = useField(); - const { collectionName, target, type, through, name } = record; + const { collectionName, target, type, through, name, template } = record; const value = record[field.props.name]; const compile = useCompile(); const form = useForm(); - const [initialValue, setInitialValue] = useState(value || field.initialValue); + const [initialValue, setInitialValue] = useState(value || (template === 'view' ? null : field.initialValue)); useEffect(() => { const effectField = ['belongsTo'].includes(type) ? collectionName @@ -251,9 +251,10 @@ export const ForeignKey = observer( } } }, [type]); + const Compoent = template === 'view' ? Select : AutoComplete; return (
-