diff --git a/.changeset/three-pumas-look.md b/.changeset/three-pumas-look.md new file mode 100644 index 0000000000..e20143d2c5 --- /dev/null +++ b/.changeset/three-pumas-look.md @@ -0,0 +1,5 @@ +--- +'@directus/app': patch +--- + +Prevent duplicate m2o field name on auto-fill recursive m2m diff --git a/app/src/modules/settings/routes/data-model/field-detail/store.ts b/app/src/modules/settings/routes/data-model/field-detail/store.ts index 8331c2bf6c..384350e870 100644 --- a/app/src/modules/settings/routes/data-model/field-detail/store.ts +++ b/app/src/modules/settings/routes/data-model/field-detail/store.ts @@ -775,6 +775,10 @@ function initLocalStore(collection: string, field: string, type: typeof localTyp state.relations[0].field = `${collection}_${currentPKField}`; state.relations[1].field = `${relatedCollection}_${relatedPKField}`; + + if (state.relations[0].field === state.relations[1].field) { + state.relations[1].field = `related_${state.relations[1].field}`; + } } }