Drupal - How do I get the route name of a view page?

The correct routename for view is view.VIEW_MACHINE_NAME.PAGE_MACHINENAME(in another word "view.$view_id.$display_id" ) . try something like following

use \Drupal\Core\Url;

$url = Url::fromRoute('view.VIEW_MACHINE_NAME.PAGE_MACHINENAME');
$form_state->setRedirectUrl($url);

and for your case

$url = Url::fromRoute('view.team.page_1'); // page_1 is my guess as to your page name, please replace it with your page machine_name

Lean more : How to formulate the route name

after @4k4 comment, Also you can redirect form to custom router with URL

just need use $form_state->setRedirectUrl($url)


To use views contextual filters as parameters use arg_X, fe.

$url = Url::fromRoute('view.team.page_1', ['arg_0' => 1234]);

The Webprofiler of the devel module let's you see the route of any page.

It also displays the number of DB queries made on the page and also the request time in addition to many other features.

It's available for Drupal 7 and 8.

Tags:

Routes

Views

8