fix(association-field): default values for the fields of a association field (#2037)
This commit is contained in:
parent
97106c28e8
commit
97a4ef7422
@ -39,10 +39,12 @@ export const AssociationFieldProvider = observer(
|
||||
if (field.value?.[collectionField.targetKey]) {
|
||||
delete field.value[collectionField.targetKey];
|
||||
}
|
||||
field.value = { ...field.initialValue, ...field.value };
|
||||
} else if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
|
||||
if (Array.isArray(field.value)) {
|
||||
field.value.forEach((v) => {
|
||||
field.value = field.value.map((v) => {
|
||||
delete v[collectionField.targetKey];
|
||||
return { ...field.initialValue?.[0], ...v };
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -65,7 +67,7 @@ export const AssociationFieldProvider = observer(
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
}, [currentMode, collectionField, field.value]);
|
||||
}, [currentMode, collectionField, JSON.stringify(field.value)]);
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user