From e920629a91757b4b8a843f991d59e0f7539f3aee Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Wed, 18 Oct 2023 10:50:25 +0800 Subject: [PATCH] fix: field in detail block should not allow config default value (#2858) --- .../schema-settings/hooks/useIsAllowToSetDefaultValue.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx b/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx index 96fc3e9a9..1a5d0716d 100644 --- a/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx +++ b/packages/core/client/src/schema-settings/hooks/useIsAllowToSetDefaultValue.tsx @@ -48,6 +48,7 @@ const useIsAllowToSetDefaultValue = ({ form, fieldSchema, collectionField }: Pro const { form: innerForm } = useFormBlockContext(); const innerFieldSchema = useFieldSchema(); const { type } = useFormBlockType(); + console.log(type); const { isAllowToSetDefaultValue = _isAllowToSetDefaultValue } = useContext(DefaultValueContext) || {}; const innerCollectionField = @@ -114,12 +115,10 @@ function _isAllowToSetDefaultValue({ ) { return false; } - - // 表单编辑状态下,不允许设置默认值 - if (formBlockType === 'update') { + // 表单非新建状态下,不允许设置默认值 + if (formBlockType !== 'create') { return false; } - return ( !form?.readPretty && !isPatternDisabled(fieldSchema) &&