I have created a webform using which people can apply for a trip. One of the fields is a selection list with dates. People select which date they would like to go. The dates for each trip vary over time.

There is one webform per trip.

Let's assume we have trip T with dates d1, d2 and d3. These dates are available on the page 'before' the webform. I.e., on that page there is a button which leads them to the webform.

I did the following.
On the page before the webform I created a form with 3 hidden values for the dates d1, d2 and d3; I created a submission button which leads to the webform. This assures the POST values d1, d2 and d3 to be present when going to the webform.

On the webform I defined a select list with 3 values: %post[d1], %post[d2] and %post[d3].

When the submit button is pressed the visitor goes to the webform and sees a select list with the correct 3 dates. The visitor selects one of the dates and clicks on Submit. Now the error "An illegal choice has been detected. Please contact the site administrator" pops up. This is strange because the value should be correct.

I search the internet, the issues in this queue and still I do not know what the cause is, how to resolve this problem.

A second problem is that if the above would work correctly, when the visitor forgets to fill in another field, the webform has forgotten the post variables and the selection list remains empty.

I am stuck here. I really hope someone can help me out here. If I should use another way to pass the dates over to the webform please let me know.

Anyway, thanks a lot for this great module!!

Comments

basby’s picture

Version: 5.x-2.1.3 » 5.x-2.6

Upgraded to latest version (5.x-2.6). Same behaviour.

basby’s picture

In stead of "post" I use "session" variables now. On the page that sends the visitor to the form I included lines like

$_SESSION['sd1'] = $d1; //$d1 is a date

In the webform I used

%session[sd1]

Now it is possible for the visitor to select the right date without an error popping up. On top of that, when the visitor forgets to fill in a required field and hits the submit button, the dates are remembered.

Be sure to initialize all session vars on each page that sends a visitor to the form.

quicksketch’s picture

Status: Active » Closed (fixed)

This issue sounds like it was self-resolved. A note for future users: the %session variable does not work for anonymous users. In the 3.x version of Webform, you can now use the %value token introduced in #300075: Introducing %value (previously %submitted) token to load submitted values, which I'd recommend over both %post and %session.