diff --git a/packages/core/client/src/block-provider/FilterFormBlockProvider.tsx b/packages/core/client/src/block-provider/FilterFormBlockProvider.tsx index 897d76f1d..850c04e7a 100644 --- a/packages/core/client/src/block-provider/FilterFormBlockProvider.tsx +++ b/packages/core/client/src/block-provider/FilterFormBlockProvider.tsx @@ -1,13 +1,14 @@ import React from 'react'; import { DatePickerProvider } from '../schema-component'; +import { DefaultValueProvider } from '../schema-settings'; import { FormBlockProvider } from './FormBlockProvider'; export const FilterFormBlockProvider = (props) => { - const { collection, resource } = props; - return ( - + false}> + + ); }; diff --git a/packages/core/client/src/collection-manager/CollectionField.tsx b/packages/core/client/src/collection-manager/CollectionField.tsx index cb91c07ec..16108e70f 100644 --- a/packages/core/client/src/collection-manager/CollectionField.tsx +++ b/packages/core/client/src/collection-manager/CollectionField.tsx @@ -5,6 +5,7 @@ import { concat } from 'lodash'; import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { useActionContext, useCompile, useComponent, useFormBlockContext, useRecord } from '..'; +import useIsAllowToSetDefaultValue from '../schema-settings/hooks/useIsAllowToSetDefaultValue'; import { CollectionFieldProvider } from './CollectionFieldProvider'; import { useCollectionField } from './hooks'; @@ -19,6 +20,7 @@ const InternalField: React.FC = (props: Props) => { const field = useField(); const fieldSchema = useFieldSchema(); const { uiSchema, defaultValue } = useCollectionField(); + const { isAllowToSetDefaultValue } = useIsAllowToSetDefaultValue(); const Component = useComponent(component || uiSchema?.['x-component'] || 'Input'); const compile = useCompile(); const setFieldProps = (key, value) => { @@ -46,7 +48,7 @@ const InternalField: React.FC = (props: Props) => { setFieldProps('title', uiSchema.title); setFieldProps('description', uiSchema.description); if (ctx?.form) { - const defaultVal = fieldSchema.default || defaultValue; + const defaultVal = isAllowToSetDefaultValue() ? fieldSchema.default || defaultValue : undefined; defaultVal !== null && defaultVal !== undefined && setFieldProps('initialValue', defaultVal); } if (!field.validator && (uiSchema['x-validator'] || fieldSchema['x-validator'])) {