I'm trying to create a special route that handles confirmation of a certain action. For instance, if I'm trying to access a route /admin/user/1/delete
, I want to go to a different route first to show a special html page that confirms they want to complete an action (ie. confirm/admin/user/1/delete) and on the page there's a confirm button that goes to the route and a go back button that redirects to the referrer.
In the example below, is there a way to allow {route} to be anything and pass that into a twig page?
/**
* @Route("/confirm/{route}", name="confirm_dialog")
* @param type $route
*/
public function confirmAction($route)
{
}
There is a cookbook covering this specific use case: http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
But I would not recommend the pattern you are trying to use. I would recommend to have the same route "/admin/user/1/delete" using GET to display a confirmation form and using POST to perform the deletion. If you don't want to repeat the code for asking confirmation, you can always extract that specific code.