fix: collectionField undefined (#2320)

This commit is contained in:
katherinehhh 2023-07-26 10:18:02 +08:00 committed by GitHub
parent 07ff868133
commit 673ea808b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -69,7 +69,7 @@ export const FormItem: any = observer(
} else if (
isVariable(schema?.default) &&
schema?.default?.includes('$context') &&
collectionField.interface === 'm2m'
collectionField?.interface === 'm2m'
) {
// 直接对多
const contextData = parseVariables('{{$context}}', variablesCtx);
@ -212,7 +212,7 @@ FormItem.Designer = function Designer() {
const isPickerMode = fieldSchema['x-component-props']?.mode === 'Picker';
const showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
const showModeSelect = showFieldMode && isPickerMode;
const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField.interface);
const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField?.interface);
return (
<GeneralSchemaDesigner>

View File

@ -1462,12 +1462,12 @@ SchemaSettings.DefaultValue = function DefaultvalueConfigure(props) {
`${collectionField.target}.${fieldSchema['x-component-props']?.fieldNames?.label || 'id'}`,
);
}
const parentFieldSchema = collectionField.interface === 'm2o' && findParentFieldSchema(fieldSchema);
const parentFieldSchema = collectionField?.interface === 'm2o' && findParentFieldSchema(fieldSchema);
const parentCollectionField = parentFieldSchema && getCollectionJoinField(parentFieldSchema?.['x-collection-field']);
const tableCtx = useTableBlockContext();
const isAllowContexVariable =
collectionField.interface === 'm2m' ||
(parentCollectionField?.type === 'hasMany' && collectionField.interface === 'm2o');
collectionField?.interface === 'm2m' ||
(parentCollectionField?.type === 'hasMany' && collectionField?.interface === 'm2o');
return (
<SchemaSettings.ModalItem
title={t('Set default value')}