简体   繁体   中英

Sonata Admin Bundle 4.5 ListView: Link again directly to /edit instead of /show

We just updated our project to symfony 4.4 and Sonata Admin 4.5. It works so far, but in the list view we are now directed to /[modelName]/[classId]/show instead of the old behaviour of ging directly to /[modelName]/[classId]/edit

Is there a way to configure the 4.5 admin bundle, so that we can jump straight to the entity edit view again?

Well, it turned out the documentation is our friend :)

final class YourEntitiyAdmin extends AbstractAdmin
{
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('id')  
            ->addIdentifier('name', null, [
                'route' => [
                    'name' => 'edit' // <-- this changes from /show to /edit
                ]
            ])
            // whatever other field you want
            ;
    }
}

I had the same question 2 days ago ! Instead of changing every Admin file you can just change the configuration in sonata_admin.yaml

sonata_admin:
    options:
        default_admin_route: edit
        skin: 'skin-black'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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