Page redirect

Page redirect after form submit on drupal 8

  1. Find the route name and variable of the page that you want to do redirection on "modules/yourModule/yourModule.routing.yml"
    User.routename://<--route name
    path: 'your_page/{var1}/{var2}'//<--variables
    defaults:
       _controller: '\Drupal\yourModule\Controller\pageController::getPage'
       _title: 'My next page'
  2. Add this script on the function submitForm.
    public function submitForm(array &$form, FormStateInterface $form_state) {
         $url = \Drupal\Core\Url::fromRoute('User.routename',['var1'=>'value1','var2'=>'value2']); 
Subscribe to RSS - Page redirect