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 (
-