My question seems to be obvious but I really don't find the solution. Well, I want to redirect to my view just after connexion. I try to use $form_state->setRedirect,but It's seems it needs the route name. I don't find the route name of my view! How to get a route name from a path? Or to redirect using the path?

marked as duplicate by Kevin, Shawn Conn, Adrian Cid Almaguer, AjitS, googletorp Sep 19 '16 at 21:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • no in this link, they say to use a route name. I don't know how to get the route name! – Asy Sep 18 '16 at 13:24
  • 3
    The route is view.[view_id].[display_id]. You find the machine name of the display in the advanced section. This is most times page_1. An example is view.frontpage.page_1 for the view of the frontpage. – 4k4 Sep 18 '16 at 15:41
  • thank you, but it doen't work I'm having this error : "Route "......" does not exist :( – Asy Sep 18 '16 at 17:33

You can also use setRedirectUrl(), which needs a URL object. There are many ways to create one, for example for an arbitrary path: Url::fromUri('base:some/path')

Not the answer you're looking for? Browse other questions tagged or ask your own question.