fix: fix default value of optional field (#2053)

* fix: fix default value of optional field

* fix: fix can not save default value
This commit is contained in:
被雨水过滤的空气-Rairn 2023-06-15 14:38:52 +08:00 committed by GitHub
parent c89d7f980f
commit 74b8687071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,6 +112,10 @@ FormItem.Designer = function Designer() {
const IsShowMultipleSwitch = useIsShowMultipleSwitch();
const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
const targetField = getCollectionJoinField(
`${collectionField?.target}.${fieldSchema['x-component-props'].fieldNames?.label}`,
);
const targetCollection = getCollection(collectionField?.target);
const interfaceConfig = getInterface(collectionField?.interface);
const validateSchema = interfaceConfig?.['validateSchema']?.(fieldSchema);
@ -353,6 +357,7 @@ FormItem.Designer = function Designer() {
'x-decorator': 'FormItem',
'x-component-props': {
...fieldSchema['x-component-props'],
targetField,
component:
collectionField?.target && collectionField?.interface !== 'chinaRegion'
? 'AssociationSelect'
@ -377,6 +382,7 @@ FormItem.Designer = function Designer() {
'x-component': 'VariableInput',
'x-component-props': {
...(fieldSchema?.['x-component-props'] || {}),
targetField,
collectionName: collectionField?.collectionName,
schema: collectionField?.uiSchema,
className: defaultInputStyle,