diff --git a/src/DefaultLink.php b/src/DefaultLink.php index 55b52d2..2317481 100644 --- a/src/DefaultLink.php +++ b/src/DefaultLink.php @@ -48,7 +48,7 @@ public function getModelLink($action, array $params = null) } $dirParts = explode('/', $url); - // replace the current action + // replace the current action if it's not an ID if (!is_numeric(end($dirParts))) { array_pop($dirParts); } diff --git a/tests/CmsActionsTest.php b/tests/CmsActionsTest.php index db7d86e..221b90c 100644 --- a/tests/CmsActionsTest.php +++ b/tests/CmsActionsTest.php @@ -253,6 +253,11 @@ public function testGetModelLink() $link = $action->getModelLink("testAction"); $this->assertEquals('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/doCustomLink?CustomLink=testAction', $link); + // in model admin with just an id + $controller->getRequest()->setUrl('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/'); + $link = $action->getModelLink("testAction"); + $this->assertEquals('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/doCustomLink?CustomLink=testAction', $link); + // in nested grid $controller->getRequest()->setUrl('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/ItemEditForm/field/OtherModel/item/0/edit'); $link = $action->getModelLink("testAction");