简体   繁体   English

如何使用一个管理类奏鸣曲管理包拥有两个列表

[英]How to have two list with one admin class sonata admin bundle

Can you help to configure two list in one class Admin so I need to override this function two times :你能帮助在一个类 Admin 中配置两个列表吗,所以我需要重写这个函数两次:

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->add('id', null, array(
            'header_style' => 'width: 5%; text-align: center',
            'row_align' => 'center'
        ))
        ->add('nom', null, array(
            'header_style' => 'width: 35%; text-align: center',
            'row_align' => 'center'
        ))  
        ->add('dateCreation', null, array(
            'header_style' => 'width: 35%; text-align: center',
            'row_align' => 'center'
        ));
}

See my answer here for how to configure custom filtered lists https://stackoverflow.com/a/41143235/5758328 in your admin menu.有关如何在管理菜单中配置自定义过滤列表https://stackoverflow.com/a/41143235/5758328 ,请在此处查看我的答案。

If you really want to have two separate configureListFields() method what you can do is make a second admin for the same entity.如果您真的想要有两个单独的configureListFields()方法,您可以做的是为同一实体创建第二个管理员。

like so:像这样:

app.admin.bar:
    class: AppBundle\Admin\BarAdmin
    arguments: [~, AppBundle\Entity\Bar, BlastCoreBundle:CRUD ]
    tags:
        - name: sonata.admin
          manager_type: orm
          group: admin

 app.admin.bar2:
    class: AppBundle\Admin\BarAdmin2
    arguments: [~, AppBundle\Entity\Bar, BlastCoreBundle:CRUD ]
    tags:
        - name: sonata.admin
          manager_type: orm
          group: admin

Then just create the second admin class and do whatever you want with it.然后只需创建第二个管理类并使用它做任何您想做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM