Redirection after an action
It would be interesting to redirect the user to the real previous page after an action on an object. (save, delete, return)
For example:
Search for an object -> edit object -> save changes -> redirection to the result of the previous search instead of the global list view
I need it for my app, I would be glad if someone know how to do it. Thanks in advance.
I think this proposal makes sense.
The easiest way to implement it that I can think of is adding a new request query parameter called return_to. In the list view we add the return_to parameter to the show and edit links (and any other link to a custom action) and then we know where to return to after show/edit actions. Any ideas to make it even simpler than this?
Maybe add the referer as a hidden field to the forms, and not override it if it's already set, so we can check directly in the form values?
Maybe use a javascript to return to the previous page? I guess this way is not the best because it checks local history but I recently saw this on a website.
You're right about the history, javascript is not a good idea
Fixed in #280. I've tested and it works OK for me: now you are always returned to the list/search page you were before showing/editing/deleting an entity.
Does the feature actually work? It seems I have a problem with it because the "return to previous page" link tries to redirect me with absolute path, fusing it with the root link of easyadmin:
The requested URL /Symfony/web/app_dev.php/admin//Symfony/web/app_dev.php/admin/?view=list&action=search&entity=CE_Commande&sortField=id&sortDirection=DESC&page=1&query=2278 was not found on this server.
Don't know if it's a problem with my namespaces or something.
@javiereguiluz , @arukado-sama : Regarding this issue, we should probably use the url twig function instead of path to generate the referer ?
I'm still a beginner so I have no idea but @javiereguiluz will know.