Reputation: 101
I have admin like "User Admin" and one child admin like "Document Admin""
admin.users:
class: App\Admin\UserAdmin
arguments: [~, App\Entity\User, SonataAdminBundle:CRUD]
calls:
- [addChild, ['@admin.documents'] ]
tags:
- {name: sonata.admin, manager_type: orm, label: Users}
public: true
admin.documents:
class: App\Admin\DocumentsAdmin
arguments: [~, App\Entity\Document, ~]
calls:
- [setParentAssociationMapping, ['user']]
- [setTranslationDomain, ['admin']]
tags:
- {name: sonata.admin, manager_type: orm, label: Documents}
public: true
And i try to remove create and delete route
App\Admin\DocumentAdmin
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->remove('delete');
$collection->remove('create');
}
But when i open this admin (/admin/app/user/1/document/list), i receive error:
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_app_user_document_create" as such route does not exist.").
Not working, but should be. I want to see child admin wit users documents without add and create buttons.
But when i open document admin directly ( /admin/app/document/list ) - everything is ok! I see list without add and edit and delete button.
How to remove routes in DocumentAdmin for both situation ?
Symfony 4 / Sonata Admin 3.35
Upvotes: 1
Views: 755
Reputation: 349
You only removed the create and delete links. You need to remove the link to list the entity too. I guess this is what you need? Add this line too.
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->remove('delete');
$collection->remove('create');
$collection->remove('list');
}
You can see list documents because you did not remove the list action from route collection.
Upvotes: 1