Search code examples
phpsymfonysonata-admin

Sonota 3.X Admin, Province switcher in dashboard


New to Symfony 3.2 and Admin generator, Symfony 1.4 was nice for a while but need to up my game.

I'm trying to keep a context in the Sonata(3.X) Admin Dashboard by using a drop down with provinces. Some entities will require the selected province as a value before reading or saving. This value will be kept in the session.

I was able to override the side_bar_nav template with a form to switch province and I was wondering what to do whit the controller/action.

Admin UI

I have overridden actions in controllers by extending CRUDController and I'm wondering if I have to rewrite every action of every controller just to switch province from the list/edit/create/batch... etc

In short, I have a hard time grasping how to have a form in side_bar_nav that change the province in the session. I Need to post the selected province and then reload the list, create, edit... etc.

Any pointers on what to override/extend in order to keep it short and sweet?

Cheers!


Solution

  • You cant just make your own controller with just one Action that will switch the province in session when called via ajax.Use javascript to send the ajax request on click of the province menu.

    You could also make your province widget an input and submit it with the form so you can retrieve it in the CRUDController action