0

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

  • By hook_form_alter we can redirect form submission. – developer Mar 8 '17 at 11:11
  • no idea how to do that – Vasmir Mar 8 '17 at 11:34
  • Doesn't webform have an option that lets you enter a URL to redirect to when complete? The 7.x version did. – Kevin Mar 8 '17 at 12:03
  • Kevin. unfortunately no. It does have an option to enter a URL where to redirect, but not to redirect after arriving on confirmation page – Vasmir Mar 8 '17 at 12:59
1
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'];
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.