Is it possible to have a form redirect the user after landing on the confirmation page back to the previous page (page of the form)?
Note: I'm using Webform for D8
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityIs it possible to have a form redirect the user after landing on the confirmation page back to the previous page (page of the form)?
Note: I'm using Webform for D8
I have written the code for d7 where the article node form once submitted it is redirected back to the form.
It will help you for d8.
/**
* Defines hook_form_alter()
*/
function demo_form_alter(&$form, $form_state, $form_id) {
if (strstr($form_id, 'article_node_form')) {
$form['actions']['submit']['#submit'] = array('demo_form_submit');
}
}
// custom submit handler for '_node_form'
function demo_form_submit($form, &$form_state) {
// call default action
node_form_submit($form, $form_state);
$form_state['redirect'] = url('node/' . 'add' . '/article', array(
'absolute' => TRUE
)
);
$_GET['destination'] = $form_state['redirect'];
}