If you stumbled upon the following error while trying to make SonataAdminBundle work:
There is no `_sonata_admin` defined for the controller `Acme\DemoBundle\Controller\PostController` and the current route `admin_acme_demo_post_list`
Here is what is wrong with your configuration.
The official documentation (in my case for ORM) says to define the *Admin service as follows:
# app/config/config.yml
services:
acme.demo.admin.post:
class: Acme\DemoBundle\Admin\PostAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: acme_demo, label: post }
arguments: [null, Acme\DemoBundle\Entity\Post, AcmeDemoBundle:PostAdmin]
Notice that null in the arguments? That is what is wrong.
That means that as the code for the admin it passes null. Whereas the correct thing to do would be to pass in the name of the service itself. Like this:
# app/config/config.yml
services:
acme.demo.admin.post:
class: Acme\DemoBundle\Admin\PostAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: acme_demo, label: post }
arguments: [acme.demo.admin.post, Acme\DemoBundle\Entity\Post, AcmeDemoBundle:PostAdmin]
Happy coding!
Not work for me.
I had to add route parameter “_sonata_admin” when i generate the url.
Hi,
Can you please give me the example how you add the route parameter “_sonata_admin” while generating the url.
Thanks,
Faisal Nasir
For me it happened when I tried forwarding requests to the listAction.
Solved by dropping forwarding and finding another way to decouple.