I created a select options with multiple values and tried to assign a different link for each value in the form submission setting. But can't because by default the web form supports only one custom url in form setting.For example in select options I have 5 values as mon ,tue,wed,thu,fri and when I will submit the form by selecting one of the above value that will redirect me to different links i.e. for each day (mon,tue,wed,thu,fri) should have different custom urls.

Comments

carl.brown’s picture

You could use Rules, which integrates with Webform. When both are installed, there's a new reaction event available in Rules called 'After a Webform has been submitted'. Use this as the trigger trigger and perform a Data Comparison against the options from your select box. Then, depending on the user's selection, use a redirect action to take the user to whatever page you want - you could also display a custom message for each option too.

govinda_roul’s picture

Thanx for responding.Can you please provide the steps to do it ?

carl.brown’s picture

I've only done it on D7 with Webform 7.x and Rules 7.x-2, but I assume it would be roughly the same as all modules exist for D6, although the exact process may differ:

Download, install and enable Webform, Rules and the magic ingredient, Webform Rules.

The last module in the list adds the ability to act on Webform submissions.

Create your webform and build the select list as normal, with the key|value pairs, like this:
mon|Monday
tues|Tuesday
wed|Wednesday
etc...

It's important to note the 'field key' value for the select box you're interested in, as we will need this later on. The help text gives it all away really "Enter a machine readable key for this form element. May contain only alphanumeric characters and underscores. This key will be used as the name attribute of the form element. This value has no effect on the way data is saved, but may be helpful if doing custom form processing."

The first part of the key|value pair is the bit you will do the data comparison against in Rules. Once you're happy with your form, head over to the Rules module.

Create a new rule and for the reaction event, select "After a Webform has been submitted".

Add a condition of type 'Content is of type' - not sure this is 100% necessary, but won't hurt as some additional validation and will ensure that the next condition has the right data.

Add an 'And' condition

Add a condition of type 'Execute PHP code'. In the text area enter something along these lines:

<?php
if( $data['name_of_select_field_key']['value'][0] ) === 'mon' {
  return TRUE;
}
?>

$data is the submitted Webform data. It's stored in a nice big Drupal style array, so it's just a case of finding the right field value. Then we check what the value of the field actually is, and return TRUE for the condition we want to test for.

Then add an action of 'Send Mail' under the 'System' heading. Add in the addresses to be emailed when a user selects this option and configure the email.

Finally, repeat this process for each of the other options in the select field, changing the recipient addresses and/or message body for each case.

If you're having problems finding the part of the submitted form data you're after, I tend to start off with a basic rule, which is just trigger on Webform submission and has one action; 'Display a message on the site'. Then in the message text area, i enter something like:

<?php
print '<pre>';
print_r($data);
print '</pre>';
?>

That will render all of the submitted form data in a nice way in the message box at the top of your page (depending on what theme you're using) and you'll be able to figure out the part you're looking for.

It could be made more tidy by using Rule Sets, so you only have one Action rule "webform submission", which triggers a Rule Set and there are separate rules for each select option within the Rule Set, but the explanation above should get the job done at least.

Hope that helps!

quicksketch’s picture

Add a condition of type 'Execute PHP code'. In the text area enter something along these lines:

Ugh, this is why I hate rules. All this work to remove PHP execution from Webform and now it's starting all over again. Nothing like storing PHP code in the database. :P

Oh well, if it works for you that's great. Please don't submit any support requests to the Webform queue when you start getting WSODs or errors in "line 0 of exec()".

carl.brown’s picture

I worked this out while trying to solve the problem of email addresses being used as keys on a select option. Nothing like putting email addresses in the source code, eh?! ;p

As it happens, the powers that be decided that there had to be a crazy business-rule-goverened workflow and so I was unable to use Webform for my situation after discovering this. But if it gets someone out of a fix...
Thanks for the module though @quickstretch. It really is pretty killer and is on my list of 'install straight away' modules :)

govinda_roul’s picture

Title: Multiple Sunmission Links with select options » Multiple Submission Links with select options

Thax for the nice steps.

How can I link to display a block or contents in the same page after the form submission ?

pipicom’s picture

Hello carl.brown,

Have followed your instructions and I have it almost done. My select code is like this:

<select class="form-select" name="submitted[hotel]" id="edit-submitted-hotel">

<option selected="selected" value="">- None -</option>
<option value="aigialos">Hotel 1</option>
<option value="argentikon">Hotel 2</option>
<option value="avli">Hotel 3</option>

</select>

Considering the above code how should I rewrite your code? Specifically i have a problem in the "name_of_select_field_key" part of the code. Not sure how I should fit name="submitted[hotel]" into this..

if( $data['name_of_select_field_key']['value'][0] ) === 'aigialos' {
  return TRUE;
}

Have tried all combinations but in vain...

Thanks again for your time..

x.algorithm’s picture

I am trying to get this to work as well.

I am using:
Rules Rules (rules) Module Enabled 7.x-2.2
Rules Rules Scheduler (rules_scheduler) Module Enabled 7.x-2.2
Rules Rules UI (rules_admin) Module Enabled 7.x-2.2
Webform Webform (webform) Module Enabled 7.x-3.18
Webform Webform Rules (webform_rules) Module Enabled 7.x-1.5

My rule is:
After webform has been submitted -> Execute custom PHP code

    if( $data['components']['type_of_boat']['value'][0] ) == '1' {
         return TRUE;
    }

-> Page redirect.

My safe key|values are:
1|Some Title
2|Some Other Title
3|A third title
4|A fourth title
5|A fifth title
6|A sixth title

Also, the rules evaluation log if this will help - I've been over it a bunch.
0 ms Reacting on event After a webform has been submitted.
12.223 ms Evaluating conditions of rule Brochure Blackjack 224. [edit]
13.614 ms The condition php_eval evaluated to FALSE [edit]
13.626 ms AND evaluated to FALSE.
13.674 ms Evaluating conditions of rule Data explosion. [edit]
13.685 ms AND evaluated to TRUE.
0 ms Rule Data explosion fires.
0.132 ms Evaluating the action php_eval. [edit]
0.519 ms Rule Data explosion has fired.
14.249 ms Finished reacting on event After a webform has been submitted.

And data explosion, which is just a print_r of the $data array is:

Array
(
    [op] => insert
    [sid] => 11
    [components] => Array
        (
            [broc_name] => Array
                (
                    [value] => Array
                        (
                            [0] => xxxx
                        )

                    [component] => Array
                        (
                            [nid] => 22
                            [cid] => 1
                            [pid] => 0
                            [form_key] => broc_name
                            [name] => Your Name
                            [type] => textfield
                            [value] => 
                            [extra] => Array
                                (
                                    [title_display] => before
                                    [private] => 0
                                    [disabled] => 0
                                    [unique] => 0
                                    [conditional_operator] => =
                                    [width] => 
                                    [maxlength] => 
                                    [field_prefix] => 
                                    [field_suffix] => 
                                    [description] => 
                                    [attributes] => Array
                                        (
                                        )

                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 1
                            [weight] => 0
                            [page_num] => 1
                        )

                )

            [physical_location_zip_code] => Array
                (
                    [value] => Array
                        (
                            [0] => xxxx
                        )

                    [component] => Array
                        (
                            [nid] => 22
                            [cid] => 2
                            [pid] => 0
                            [form_key] => physical_location_zip_code
                            [name] => Physical Location (Zip Code)
                            [type] => textfield
                            [value] => 
                            [extra] => Array
                                (
                                    [description] => Please enter your zip code.  This will help guide you to the correct dealer
                                    [title_display] => before
                                    [private] => 0
                                    [disabled] => 0
                                    [unique] => 0
                                    [conditional_operator] => =
                                    [width] => 
                                    [maxlength] => 
                                    [field_prefix] => 
                                    [field_suffix] => 
                                    [attributes] => Array
                                        (
                                        )

                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 1
                            [weight] => 1
                            [page_num] => 1
                        )

                )

            [email] => Array
                (
                    [value] => Array
                        (
                            [0] => xxxx
                        )

                    [component] => Array
                        (
                            [nid] => 22
                            [cid] => 3
                            [pid] => 0
                            [form_key] => email
                            [name] => Email
                            [type] => email
                            [value] => 
                            [extra] => Array
                                (
                                    [description] => Please enter your Email if you wish for us to be contacted.
                                    [title_display] => before
                                    [private] => 0
                                    [disabled] => 0
                                    [unique] => 1
                                    [conditional_operator] => =
                                    [width] => 
                                    [attributes] => Array
                                        (
                                        )

                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 2
                            [page_num] => 1
                        )

                )

            [phone] => Array
                (
                    [value] => Array
                        (
                            [0] => xxxxxxx
                        )

                    [component] => Array
                        (
                            [nid] => 22
                            [cid] => 4
                            [pid] => 0
                            [form_key] => phone
                            [name] => Phone
                            [type] => textfield
                            [value] => 
                            [extra] => Array
                                (
                                    [description] => Please enter your phone number.
                                    [title_display] => before
                                    [private] => 0
                                    [disabled] => 0
                                    [unique] => 0
                                    [conditional_operator] => =
                                    [width] => 
                                    [maxlength] => 
                                    [field_prefix] => 
                                    [field_suffix] => 
                                    [attributes] => Array
                                        (
                                        )

                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 3
                            [page_num] => 1
                        )

                )

            [type_of_boat] => Array
                (
                    [value] => Array
                        (
                            [0] => 1
                        )

                    [component] => Array
                        (
                            [nid] => 22
                            [cid] => 6
                            [pid] => 5
                            [form_key] => type_of_boat
                            [name] => Type of Boat
                            [type] => select
                            [value] => 
                            [extra] => Array
                                (
                                    [description] => Please select the kind of boat you are interested in.
                                    [items] => 1|Some Title                                              
                                              2|Some Other Title
                                              3|A third title
                                              4|A fourth title
                                              5|A fifth title
                                              6|A sixth title
                                    [multiple] => 0
                                    [title_display] => before
                                    [private] => 0
                                    [aslist] => 1
                                    [optrand] => 0
                                    [conditional_operator] => =
                                    [other_option] => 
                                    [other_text] => Other...
                                    [custom_keys] => 
                                    [options_source] => 
                                    [conditional_component] => 
                                    [conditional_values] => 
                                )

                            [mandatory] => 0
                            [weight] => 5
                            [page_num] => 1
                        )

                )

Thanks for any assistance you can give me.
I've referenced several posts already:
http://drupal.org/node/1505298
http://drupal.org/node/1700638
http://drupal.stackexchange.com/questions/32730/webform-redirect

The current one seems to be the most relevant.

quicksketch’s picture

Category: Feature request » Support request
Priority: Major » Normal
Issue summary: View changes
Status: Active » Closed (fixed)

Sorry for my unhelpful post in #4. PHP code in the database (and Rules) get me wound up some times.

In any case, if you're using Webform Rules, please post to the Webform Rules queue. I'm glad everyone seems to have found a solution here.