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) {