From bd6cab8989ea8a8af3b0848c51ee9b3fae289ab3 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Mon, 24 May 2021 13:20:01 -0400 Subject: [PATCH] Prevent duplicate field name on recursive m2m --- .changeset/three-pumas-look.md | 5 +++++ .../modules/settings/routes/data-model/field-detail/store.ts | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .changeset/three-pumas-look.md 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}`; + } } }