1

I am trying to build an html form that is stretched across several pages. My intention is to use the GET method to send all of the fields data in the query string (URL parameters) and then store this data in hidden fields on the next page. I need to know how to append the data to the URL and how to retrieve it on the next page. I think I will need to send information across at least three pages. I have searched for a way to do this but I haven't really gotten a clear explanation. I am somewhat new to HTML coding. This is the most difficult thing I have attempted to code. Also, (this is not strictly necessary) but I would like to show this information as dynamic text as well. So I can show that certain pieces information have been added to the form. This needs to be separate from the actual form though. Thank you in advance. Any help is greatly appreciated.

0

You need to write a multistep form with the Form API and CTools.

The Form API allows you to write forms: See Creating a builder function to generate a form.

Because your form is multistep you need CTools to implement it, and handles issues like carry those values over the different steps.

This two subjects are too broad to explian in an answer, but there's lot of documentation about them.

0

Actually, you have multiple option to achieve what you want:

  1. As previously suggested, you could use CTools to build a multi-page form. This tutorial has a pretty decent step-by-step.

  2. You can create a form that uses collapsible tabs. It will look like a multi-page form without the complications of having to pass parameters through.

  3. You can hand-code a succession of forms, each with its own menu path so that you can redirect from one to the next upon clicking submit. In this case you don't have to explicitly fill the GET parameters since each form submits its values in the POST and you can harvest them using drupal_get_query_parameters() and store them in hidden fields in the subsequent form.

Which approach works best for you depends on how your data is structured and whether you need to store intermediate status of the form. For example, is filling out only the first part a valid response? Can users skip step 2 and only do 1 and 3?

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.