EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Redirection after an action

Open arukado-sama opened this issue 11 years ago • 8 comments

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.

arukado-sama avatar May 05 '15 12:05 arukado-sama

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?

javiereguiluz avatar May 06 '15 18:05 javiereguiluz

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?

Pierstoval avatar May 06 '15 19:05 Pierstoval

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.

arukado-sama avatar May 07 '15 07:05 arukado-sama

You're right about the history, javascript is not a good idea

Pierstoval avatar May 07 '15 07:05 Pierstoval

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.

javiereguiluz avatar May 07 '15 13:05 javiereguiluz

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.

arukado-sama avatar May 11 '15 08:05 arukado-sama

@javiereguiluz , @arukado-sama : Regarding this issue, we should probably use the url twig function instead of path to generate the referer ?

ogizanagi avatar May 11 '15 08:05 ogizanagi

I'm still a beginner so I have no idea but @javiereguiluz will know.

arukado-sama avatar May 11 '15 08:05 arukado-sama