Form redirection on submit | Drupal 8

Form redirection on submit

Submitted by editor on Fri, 01/15/2016 - 17:55

How to redirect a form after submission

Example : (Insert this line in to your form submitForm() methode)

Redirect to the user page ( Redirection on form submit)

Redirect to a custom page



  public function submitForm(array &$form, FormStateInterface $form_state) {

Using a Url Object (use Drupal\Core\Url)

$url = Url::fromRoute('', [
  'arg1' => "value1",
  'arg1' => "value2",


zaibatsu (not verified)

Thu, 03/17/2016 - 09:05


If i want to redirect a form to a view page? how can i do that?

$form_state->setRedirect(''); ? how would i get the route name?

can you please help? Thanks

Pavel (not verified)

Fri, 04/28/2017 - 07:47

When i use $form_state->setRedirect('<front>'); i get nothing in $_POST array on front page. How can i send post data of form with setRedirect?

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.