The Webform module is great, but the documentation on http://drupal.org/handbook/modules/webform doesn't seem to be complete. That's why i'm not sure if my question is a feature request, a support request or a bug report... I just can't find out if Webform is supposed to have this feature.

On my form, I want an e-mail field (for the submitter's email address) and a checkbox saying "send a copy to my email addres". On submission, the copy should only be sent to the submitter if the checkbox is checked.

Can someone please explain how 'Conditional e-mail recipients' and 'E-mail a submission copy' work together and if I can get it to work the way I want? Thanks.

Comments

quicksketch’s picture

'Conditional e-mail recipients' and 'E-mail a submission copy' are in fact the same option located in two separate places. If you uncheck one it should uncheck the other (and the same for checking an option).

Usually the conditional e-mail recipients can be used in a select list (or checkbox/radios) in a way like this:

myemail1@example.com|Person 1
myemail2@example.com|Person 2
myemail3@example.com|Person 3

Checking Person 1 would then send an email to myemail1@example.com. Unfortunately because you don't actually have the user's e-mail available before they fill out the form, the conditional e-mail recipients can't actually do what you're wanting. You'll need to use the additional submission code to add the user's e-mail address to the list of recipients.

// Send the user an e-mail (using the value of a "user_email" field) if the checkbox named "cc" is checked.
if ($form_values['submitted_tree']['cc']) {
  $node->webform['additional_emails'][] = $form_values['submitted_tree']['user_email'];
}
marcvangend’s picture

Quicksketch, thank you for the quick reply and the explanation.
The code you gave for the additional processing field almost worked for me. I say almost, because (in order to get a checkbox instead of a radio button) I chose to set the 'cc' select to 'multiple values', which creates another array within the submitted_tree. This code works for me:

<?php
// Send the user an e-mail (using the value of a "user_email" field) if the checkbox named "cc" is checked.
if ($form_values['submitted_tree']['cc']['cc']) {
  $node->webform['additional_emails'][] = $form_values['submitted_tree']['user_email'];
}
?>

(By the way, if there is a better way to get a single on/off checkbox, I'd like to know. Maybe it would also be nice to have a boolean field type, which is a single checkbox by default.)

quicksketch’s picture

Status: Active » Closed (fixed)
amogiz’s picture

Hi, i noticed that it is not possible to have same email adresses for one list.
Exemple :
myemail1@example.com|Item 1
myemail2@example.com| Item 2
myemail2@example.com| Item 3

Any idea ?

muddum’s picture

Version: 5.x-2.0-beta3 » 6.x-2.9
Category: support » feature
Status: Closed (fixed) » Needs work

I am having this issue as well - I need to have a list that emails some of the same addresses for different issues:
custsvc@xyz.com| - Please Select Topic -
lchristo@xyz.com,custsvc@xyz.com|Media
llewis@xyz.com,rcole@xyz.com,board@xyz.com|Board of Directors
webmaster@xyz.com,custsvc@xyz.com|Web Site Issues
webmaster@xyz.com,custsvc@xyz.com|Online Orders
...

Right now I cannot do it and that seems non-optimal; why should option values have to be unique?

quicksketch’s picture

Version: 6.x-2.9 » 5.x-2.0-beta3
Category: feature » support
Status: Needs work » Closed (fixed)
clawki’s picture

muddum and amogiz,

I assume that you are long passed this issue, but since I had tracked down a solution I thought that I would add it so that is anyone else ran across this issue. I am assumign the version is Drupal 5 is a similar fix to the one in D6 which is to add a space at the end of the email address i.e.:

email1@drupal.org|Option 1
email1@drupal.org |Option 2
email1@drupal.org |Option 3

Hope this helps someone.

Tally Ho.

KC

emilkarl’s picture

#7 works in D7 too. Thanks!