Redirect to another admin

265 views
Skip to first unread message

Rob Tam

unread,
May 15, 2017, 12:33:00 PM5/15/17
to sonata-users
Hello guys,
I begin to use Sonata admin in memory of the old symfony admin generator.
I remember that it was possible to redirect to another admin on a list action for instance.

I want to set up a new list action that will redirect to another admin BUT this other admin should be pre filled with some datas

ie: list action on user -> click -> open other admin 'mail' on the creation form -> mail form has a field user_id that should be set to the user linked on the first admin list.

Is this possible with sonata ? Any clues on how to do this ?

Thanks

Matias Vadino

unread,
Jul 18, 2017, 2:56:46 PM7/18/17
to sonata-users
Hi Robert, I'm trying to do the same as you, do you find a way to add a link from a from?

I found that you can add buttons to controllers in lists but not in forms:

Message has been deleted

Edi Camas

unread,
Jul 22, 2017, 12:51:52 PM7/22/17
to sonata-users
You can overryde the create template and extend it from the base, remember to send the user parameter. Then change the form URL  in the extended base view to execute an action to send the mail.

admin.multimedia:
        class: AppBundle\Admin\MultimediaAdmin
        arguments: [~, AppBundle\Entity\Multimedia, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: Multimedia }
        calls:
            - [ setTemplate, [list, AppBundle:Multimedia:multimedia_list.html.twig]]

with calls you can overryde the template and change what do you want.

Try it.
Reply all
Reply to author
Forward
0 new messages