I am rather new to Symfony (2 weeks) so forgive my ignorance.
I am trying to add a custom action button that will link to a pre filtered list of a RELATED entity. I have done a lot of research but can't quite seem to find what I need.
Currently I have two entities Books and Authors with a manyToOne relation ship. I have these set up in Sonata Admin in the usual way and all works well. I even have an author filter on the book list page which I am hoping can be leveraged to accomplish my goal.
In the Author list view, I would like to add an action button on each row next to View and Edit, called "View Books By Author". I can get the button but fail to correctly build the URL.
I have 3 issues with the routing:
1) I am trying to use admin.generateObjectUrl() or similar in my button template to cleanly build an admin URL but can't get a path to an alternate entity. In my case, since I am currently viewing authors, the links always point to the author entity not books as I would like.
2) I am uncertain how to get the id of the current author in order to pass it to the filters
3) I am uncertain how to cleanly build the filter query string parameters. I could do it by hand if necessary: bookEntityListPath + "?filter[author][value][]=" + $authorID But obviously this is not that clean and I would prefer a better method if possible.
Thanks in advance!!!