Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Drupal - Redirect after form submission

In your "submitForm" method write below code

 $form_state->setRedirect('machine_name');
 return;

where machine_name is the machine name mentioned in the routing file.

I hope this helps .. :)


If you want to set at buildform you need to use some routing path like.

use Drupal\Core\Url;

$url = Url::fromRoute('route.path');
$form_state->setRedirectUrl($url);

Tags:

Forms

8

Redirection

Related

Drupal - Building a search View that respects access control Drupal - Is Drupal Console aimed to replace Drush? Drupal - How do I implement hook_views_query_alter()? Drupal - What is the appropriate way to get items from an entityqueue? Drupal - How do I theme a link? Drupal - How do I print the SQL query of a view in front end? Drupal - Place a block inside a twig template Drupal - Delete a node after X weeks it was created Drupal - How can I programmatically change the active theme? Drupal - How do I get a module path? Drupal - Add a local task tab for a content type only Drupal - Possible to turn off Twig debug mode for a specific template?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy