There is no `_sonata_admin` defined for the controller

2,200 views
Skip to first unread message

Tomasz I

unread,
Apr 5, 2013, 7:18:15 PM4/5/13
to sonata...@googlegroups.com
HI,

I have weird bug with newest SOnataAdminBundle 2.2

I have an Admin classs, I've set Admin Class for it, service and Controller in order to add a function there.

services:
    sonata.admin.card:
        class: MyConpany\BlaBlaBundle\Admin\CardAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: Cards, label: "Cards" }
        arguments: [sonata.admin.card, MyConpany\BlaBlaBundle\Entity\Card, BLBundle:CardAdmin]    


Then a controller as always extending CRUDController. ANd finally one of my field in admin lsit has it's own template which calls controller action:

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}

{% block field %}
    {{ render(controller("BLBundle:CardAdmin:getCardNbFromToken", {'t': object.token})) }}
{% endblock %}


With this a have an error like this:

An exception has been thrown during the rendering of a template ("There is no `_sonata_admin` defined for the controller `MyConpany\BlaBlaBundle\Controller\CardAdminController` and the current route ``") in "SonataAdminBundle:CRUD:list.html.twig".


Any guess what could it be?

Tiago Garcia

unread,
Jul 1, 2013, 12:07:44 PM7/1/13
to sonata...@googlegroups.com
Hi,

{% block field %}
    {{ render(controller("BLBundle:CardAdmin:getCardNbFromToken", {'t': object.token, '_sonata_admin' : 'sonata.admin.card'})) }}
{% endblock %}

cheers

Jakala

unread,
Jul 3, 2013, 2:17:00 AM7/3/13
to sonata...@googlegroups.com
maybe im wrong, but all my sonata services has the first argument null, second the entity and third the controller...

I think your service must be:


services:
    sonata.admin.card:
        class: MyConpany\BlaBlaBundle\Admin\CardAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: Cards, label: "Cards" }
        arguments: [null, MyConpany\BlaBlaBundle\Entity\Card, BLBundle:Card ]

the last argument (BlBundle:Card ) refers to MyConpany\BlaBlaBundle\Controller\CardController file
Reply all
Reply to author
Forward
0 new messages