I have an initial webform (based on 3.x of webform module/Drupal 7) that needs to redirect to a second form if yes is specified in a yes/no choice. Otherwise if No, the first form should submit normally (with a webform result).
Also, if yes is entered on the first form, on submitting the form, the webform result is not to be stored for this form, but the webform result will be stored on the second webform. Values entered in the first form are carried through to the second, to autofill, I use the PHP _SESSION variable to do this.
I'm having difficulty getting this to work completely. It always seems that I can get one part of the above working, but not the other. I'm using the standard approach of hook_form_alter and within this trying various combinations of setting the validate array and submit array and the form redirect property to do the redirect from the first and second form.
My approach now is to have a validate handler function to change the submit handler if the yes is chosen (for proceeding to the second form). Submitted values on the first form are available to the validate handler. The submit handler can do the redirect to the 2nd form.
But when I change the submit handler from within the validate handler, I see that this change gets overwritten by Drupal itself and I don't know why.
I have also found that the submit handler - which I use to set the form redirect, for the 'yes' choice - will not work if other submit handlers are present in the submit handler array. I have to empty the array and have only my function in it.
I had wanted to deal with the yes/no choicepoint at this stage in my own submit handler, but if I had to 'throw away' the other submit handlers, then the 'No' path won't work - the webform result won't get submitted.
Another approach I tried, to counteract my deleting of the other existing default submit handlers, was to programmatically submit a form for the the first form for the 'No' path so that it would get saved. However doing this I got an error about the number of submissions possible, even though it was set to unlimited (-1) in the config. From that I concluded that it was due to that I had already started the first form as a visitor and somehow the webform system 'notes' that, so programmatically submitted form would exceed that supposed maximum.
Note: I can't upgrade to webform 4.x as there are other forms on the site which may be impacted unexpectedly.