mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 15:26:02 +00:00
fix: fix error with setting default value for date type
This commit is contained in:
parent
ea33974ec5
commit
0a8fd44816
@ -4,6 +4,7 @@ import { Field } from '@formily/core';
|
|||||||
import { ISchema, Schema, observer, useField, useFieldSchema } from '@formily/react';
|
import { ISchema, Schema, observer, useField, useFieldSchema } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import moment from 'moment';
|
||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ACLCollectionFieldProvider } from '../../../acl/ACLProvider';
|
import { ACLCollectionFieldProvider } from '../../../acl/ACLProvider';
|
||||||
@ -688,5 +689,9 @@ function isFileCollection(collection: Collection) {
|
|||||||
FormItem.FilterFormDesigner = FilterFormDesigner;
|
FormItem.FilterFormDesigner = FilterFormDesigner;
|
||||||
|
|
||||||
export function getFieldDefaultValue(fieldSchema: ISchema, collectionField: CollectionFieldOptions) {
|
export function getFieldDefaultValue(fieldSchema: ISchema, collectionField: CollectionFieldOptions) {
|
||||||
return fieldSchema?.default || collectionField?.defaultValue;
|
const result = fieldSchema?.default || collectionField?.defaultValue;
|
||||||
|
if (collectionField?.uiSchema?.['x-component'] === 'DatePicker' && result) {
|
||||||
|
return moment(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user