• 1

When you create a new page in Drupal 8 it redirects the user to that page on the site, I would like it to redirect back to the content section of the Admin interface.

Is there a way to do this?


You need to create a custom module and use


You would start by checking what form it is and then add a custom submit callback like so

function your_module_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // test you are altering the correct form so wrap the below in an IF
  $form['actions']['submit']['#submit'][] = '_your_module_custom_redirect';

function _your_module_custom_redirect($form, FormStateInterface $form_state) {
  $form_state->setRedirect('your route name');

or possibly use hook_ENTITY_TYPE_insert() as I think hook_form_alter will run regardless of validation, but I am not 100% on that

  • 0
Reply Report