Search code examples
phpsymfonysonata-adminsymfony-sonata

Remove child admins from sidemenu in sonata-admin


I have one EmployeeAdmin in sonata-admin, configured with three child admins:

sonata.admin.employee:
    class: Medicina\InasistenciasBundle\Admin\EmployeeAdmin
    tags:
        - { name: sonata.admin, manager_type: orm, group: "Contenido", label: "Empleados", label_translator_strategy: "sonata.admin.label.strategy.underscore" }
    arguments:
        - ~
        - Medicina\InasistenciasBundle\Entity\Employee
        - MedicinaInasistenciasBundle:EmployeeCRUD
    calls:
        - [ setTranslationDomain, [MedicinaInasistenciasBundle]]
        - [ addChild, [@sonata.admin.compensatory_part]]
        - [ addChild, [@sonata.admin.compensatory]]
        - [ addChild, [@sonata.admin.absence]]

the child admins are all pretty much the same, here's one of them:

 sonata.admin.compensatory_part:
    class: Medicina\InasistenciasBundle\Admin\CompensatoryPartAdmin
    tags:
        - { name: sonata.admin, manager_type: orm, group: "Contenido", label: "Módulos de Tiempo",label_translator_strategy: "sonata.admin.label.strategy.underscore" }
    arguments:
        - ~
        - Medicina\InasistenciasBundle\Entity\CompensatoryPart
        - MedicinaInasistenciasBundle:DeleteValidationCRUD
    calls:
        - [setTranslationDomain, [MedicinaInasistenciasBundle]]

How can I avoid the child templates from showing up in sonatas side menu?

screenshot of sonata menu

I have tried removing the group and label tags, but then sonata just sticks them in an 'Default' group with no name. I'm sure is something trivial, but I can't seem to find it in the documentation. Any ideas?


Solution

  • Add the show_in_dashboard: false tag to the Admin services you wish to exclude from the menu.

    tags:
        - { name: sonata.admin, manager_type: orm, group: "Contenido", label: "Módulos de Tiempo",label_translator_strategy: "sonata.admin.label.strategy.underscore", show_in_dashboard: false }
    

    Keep the group and label tags so they show up correctly in collections and type admins!