I've been doing a [back][next] to [finish] set of forms for user input fields, think of it like a questionnaire for user info where the user can still go back to the previous pages to update their info.. until it reaches the end of the pages to [finish]
I've done this before (hardcoded) but my code is too long and all the debugging gave me a headache. My first approach was:
- Use a PHP case to find out which phase/step the user is in now
- If the user clicks on [next], the page variable appends a +1 to the page count
- If the user clicks on [back], the page var deducts -1 to the page count, until it reaches [finish]
- If the user leaves the page for some reason and comes back to it, the session/cookie saved fills in the form values and which phase/step the user is in
This method of mine isn't very dynamic as the php case is hardcoded to a set of page numbers & phases, if the client wants to add another page; that can be a problem.
I'm new to Drupal; maybe Drupal already has some part of the API that makes this [back][update][next][finish] easier, or a easier way to store cookies? If by PHP only, is there a better approach?