drupaldrupal-forms

Pass hidden value of a form and retrieve it in thank-you page


Is there a solution to get a value to a thank-you page that is not GET?

For a marketing and analytical issue, I need to retrieve the form_id on the thank-you page of the form from which it comes.

Several forms go to the same thank-you page.

Is it viable for custom.php to launch the thank-you page?

enter image description here

In addition, Drupal's form settings forces to use one of these redirects enter image description here

With GET all will be easier, but I don't want to add params in the URL.

Thanks for clarifying me solutions


Solution

  • You can try same with two ways.

    a. Using session

    b. Using LocalStorage

    a) Using session when you submit the form.Just store value in you session

    $_SESSION['form_id'] = 'xyz';
    

    In thankyou page you get use it:

    echo $_SESSION['form_id];
    

    Note: Make Sure start your session before set value.

    b) Second way is html5 local storage.

    localStorage.setItem("form_id", "xyz");
    

    And over thankyou page you can get this value

    localStorage.getItem("form_id");