From 54e8c801cc06cd3f5ddacd32ca291da5fd0183a5 Mon Sep 17 00:00:00 2001 From: Maximilian Graf Schimmelmann Date: Wed, 10 Apr 2024 09:29:32 +0200 Subject: [PATCH] Admin Url Fix for linking from Edit/Detail to Index pages. --- src/Router/AdminUrlGenerator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Router/AdminUrlGenerator.php b/src/Router/AdminUrlGenerator.php index ae6afbbd13..0992917d00 100644 --- a/src/Router/AdminUrlGenerator.php +++ b/src/Router/AdminUrlGenerator.php @@ -284,6 +284,11 @@ public function generateUrl(): string $this->unset(EA::DASHBOARD_CONTROLLER_FQCN); } + // if the current action is 'index' and an entity ID is defined, remove the entity ID to prevent exceptions automatically + if (Action::INDEX === $this->get(EA::CRUD_ACTION) && null !== $this->get(EA::ENTITY_ID)) { + $this->unset(EA::ENTITY_ID); + } + // this happens when generating URLs from outside EasyAdmin (AdminContext is null) and // no Dashboard FQCN has been defined explicitly if (null === $this->dashboardRoute) {