Hi guys,
I have a question about creating mutlipage webforms.
I have a 4 pages questionnaire made with the module webform. All my questions have radio buttons or checkbox options. On the Additional Validation, when I write :
if($form_values['submitted_tree']['questionPage1']=='answerPage1'){ echo ' page 1 works';} or
if($form_values['submitted_tree']['questionPage2']=='answerPage2'){ echo ' page 2 works';} or
if($form_values['submitted_tree']['questionPage3']=='answerPage3'){ echo ' page 3 works';} none of those lines works, but if i write
if($form_values['submitted_tree']['questionPage4']=='answerPage4'){ echo ' page 4 works';} it works fine. The submit button is on the page 4, but I thought the values of the previous pages would go through all the pages of the form.
How could I do that to be sure all my values are going through all the pages of the form, so, I can write an if on any of values of any page?
please help!
Thanks a lot.
Comments
Comment #1
quicksketchYou cannot use echo here because the results are run within an eval() statement, and are never printed to the page. Install devel module and use dsm() instead. I don't provide support on writing custom code.
Comment #2
voxy commentedHi, thanks for your answer, but in fact, I provided a bad example (sorry for that), I don't really do an echo in my code. I resume what I want :
I need to use the answer of each question to calculate and display a score in the result page:
- I have 4 categories of questions (1 category per page) and 2 questions per category (total 8 questions)
- Each question has 4 choices of answer (the options) and each options has a grade (A if you choose this, B if you choose that ...) .
- When user click on submit, he as a result page with his score calculated per category and the Final score.
So, I created the questionnaire and the code to calculate the scores but it doesn't work, because I can't recover the values of the first pages, and only those of the last page work in the if.
Do you see what I mean?
PS: I use the devel module too
Comment #3
quicksketchYou can always check any submitted values in $form_state['storage'], which should contain (I think) all the submitted values thus far on all pages.
Comment #4
voxy commentedyou'r right, I just needed the $form_state['storage']. Thanks.
Comment #5
quicksketch