Search code examples
restsymfonysonata-adminsymfony-sonatasonata

add RESTful action in sonata-admin


I added a new action (fooAction) in sonata admin bundle. In list view there is an attribute which linked to newAction, but the its URL is like this : admin\bundle\entity\foo?id=17 fooAction works correctly ,But I want the Url to be RESTful like this: admin\bundle\entity\17\foo
what should I do ?


Solution

  • In configureRoutes function,you must replace this :

    $collection->add('foo');
    

    to :

    $collection->add('foo',$this->getRouterIdParameter() .'/foo');