Hi,

I've got a large multi-page form (upwards of 11 pages depending on what user wants to fill in) that works, but for certain pages drupal intercepts the submit button and redirects to the first page (losing any entered variables for the last page the user was on).

The way I'm handling everything is:
Each form has a hidden variable that keeps track of the current page.
At the top of my page function, I'm checking for this variable in $_POST['edit'].
If it exists, I call a function to write the data to a specific db table, then build+render the form that corresponds to the submit button the user just pressed.
But on certain pages and for certain conditions, drupal resets the form and the $_POST and I can't work out why?
So if I goto page 1, enter some text, then click page 1's button; drupal resets the form
If I fill stuff in in a 'natural' order everything's fine until I get to a group of sub-category forms where drupal resets the form.

The user has to have the choice of filling in whatever data they want, and in whatever order. They also (due to the size of the thing!) need to be able to come back to it at a later date.

Is there anyway to tell the forms api now to reset the form?

I've seen a few posts regarding using $form['#redirect'] = FALSE; but what does it actually do, and would I need to change the way I'm doing things, ie doing the db stuff after rendering the form?

So confused, (and this problem has been annoying me for a week now!)

Cheers for any help/guidance

Comments

fronbow’s picture

I solved this by splitting the app up into individual forms (about 26 of the things!).

The modules page takes a bit of a hammering (memory-wise) but at least it works as intended now.

rlbravo’s picture

Franbow:

I need to develop a module like yours and i have a few problems that don´t know how to solve. I would realy apreciate if you could send me your module to have an idea of the stucture that put´s together all those forms.

My email is rafaelbravo@gmail.com.

Thanks for your time!

rlbravo

fronbow’s picture

Hi rlbravo,

I can't send you my module as it's not mine to sell. I'm getting paid to develop it at work (it's one of my many projects!). But I can try and help in other ways if you let me know what it is you're stuck with?
The logic basically goes something like this:
You have a main function that calls the forms and does the database manipulation.
When each form fires, output gets sent back to the main function which works out where to go next.
The form has a hidden var that tells the main function which form is being submitted, whilst the submit button of the form tells the main function which form to redirect to if that form passes all checks.
A requirement of the project is that the user can fill the form in in whatever order they choose and they are allowed to 'save' it so that they can come back to it later (the size of the form can mean it can take at least an hour to fill it in!)

Cheers

fronbow

newtodrupal’s picture

Hi, I am also a newbie to drupal and i am also working on multi step form.... i also encountered the same problem. I did not understand what you meant by splitting up the app into individual forms..

How do i solve the problem.......
Any help would be greatly appreciated

chx’s picture

http://jeff.viapositiva.net/drupal/dynamic-forms might help you.
--
The news is Now Public | Drupal development: making the world better, one patch at a time. | please donate

--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.

fronbow’s picture

I looked at this originally, but it kind of implies/expects a form to be completed in one go(visit).

Whereas one of the requirements for my form/project was to be able to come back to it at a later date and to still have all your data in the form.