问题
I would like to hide "Download" button on Sonata Admin from some of custom entity. How to hide/delete it?
If i override base_list.html.twig
and remove the download button from table_footer, it disappears all of entity lists. Is there any way to hide it from Admin class?
回答1:
You can hide the "download" button by removing the corresponding route:
class YourClass extends AbstractAdmin {
public function configureRoutes(RouteCollection $collection) {
$collection->remove('export');
}
}
回答2:
PROBLEM SOLVED!
I solved it by managing user roles. For example:
You want to remove Download button in Post section. So you need to add below code in app/config/security.yml
security:
role_hierarchy:
ROLE_PUBLISHER:
- ROLE_ADMIN_POST_CREATE
- ROLE_ADMIN_POST_EDIT
- ROLE_ADMIN_POST_LIST
- ROLE_ADMIN_POST_VIEW
- ROLE_ADMIN_POST_EXPORT #If you comment or delete this line. Download button don't show in Sonata Post List.
来源:https://stackoverflow.com/questions/38734213/hide-download-button-in-sonata-admin