Under 5.x-1.3, with a 'select' field set as the source for the E-mail subject, E-mails came through with the default email subject (ie: 'Form submission from: $title').

Having upgraded to 5.x-1.4, the emails from the same form are coming through with blank titles.

From a brief skim of the file it looks as though the 'select' field type has been added to the $possible_email_subject conditional on line 613 of webform.module, and then missed out of the custom SUBJECT: field check on line 1379.

line 613:
if (in_array($type, array('textfield', 'hidden', 'select'))) {
line 1379: if ($type == 'textfield' || $type == 'hidden') {

I'd submit a patch myself but (a) I don't have any patch generation software and (b) I don't know if any additional work would need to be done to get the display value of the select box instead of the submitted value.

Hope that helps...

CommentFileSizeAuthor
#6 webform_subject_select.patch1.83 KBquicksketch

Comments

kingandy’s picture

I am still experiencing this issue. Any suggestions? Anyone? Bueller?

kingandy’s picture

Status: Active » Needs review

OK, I've tried lifting out the following section:

          if ($type == 'textfield' || $type == 'hidden') {
            if ($component['name'] == $node->email_from_name) {
              $email_from_name = strip_tags($form_values['submitted'][$cid]);
            }
            if ($component['name'] == $node->email_subject) {
              $email_subject_string = strip_tags($form_values['submitted'][$cid]);
            }
          } elseif ($type == 'email' && $component['extra']['carboncopy'] == 'Y' ) {
            $headers['Cc'] = $form_values['submitted'][$cid];
          }

And replaced it with the following (I thought I'd optimise the repeated 'if' statements into a SWITCH statement while I was there):

          switch ($type) {
            case 'textfield':
            case 'hidden':
              if ($component['name'] == $node->email_from_name) {
                $email_from_name = strip_tags($form_values['submitted'][$cid]);
              }
              if ($component['name'] == $node->email_subject) {
                $email_subject_string = strip_tags($form_values['submitted'][$cid]);
              }
            break;
            case 'email':
              if ( $component['extra']['carboncopy'] == 'Y' ) {
                $headers['Cc'] = $form_values['submitted'][$cid];
              }
            break;
            case 'select':
              $formitem = _webform_render_select($component);
              $selectvalue = $formitem['#options'][strip_tags($form_values['submitted'][$cid])];
              
              if ($component['name'] == $node->email_from_name) {
                $email_from_name = $selectvalue;
              }
              if ($component['name'] == $node->email_subject) {
                $email_subject_string = $selectvalue;
              }
            break;
          }

That seems to have sorted it, and even retrieves the displayed value rather than the form-safe value. I've not tested it in every case, though, so I'd welcome input.

I'm going to mark this as 'patch (code needs review)' though I haven't written an actual patch file since, as noted above, I have no patch file writing software. If somebody could do so please feel free :)

quicksketch’s picture

Status: Needs review » Closed (duplicate)

I'm pretty sure this was fixed in http://drupal.org/node/158238

kingandy’s picture

Status: Closed (duplicate) » Needs review

That patch doesn't touch the implementation section - it's amending the part where it decides what options are available, but doesn't affect the completely separate function which takes the configured options and applies them to the generated email (function webform_client_form_submit).

Also it appears to be a patch for 4.7 (though obviously any decent code monkey could pick out the changes and apply them to the 5.x code).

A quick check of 5.x-1.6 confirms that it's still using the if ($type == 'textfield' || $type == 'hidden') logic, though it has altered slightly to incorporate the 'email' case. The 'select' case is still not accommodated in the webform_client_form_submit function, only 'email', 'hidden' and 'textfield'.

quicksketch’s picture

Thanks, it is indeed a separate issue. One question about the code posted though, shouldn't the 'key' value be used for select lists rather than the 'value' (in key|value pairs). Let's say you had a dropdown like this:

bob@company.com|Bob Fisher, President
joe@company.com|Joe Blow, Technical Contact
phil@company.com|Philster, Marketing

You'd want the key values used, rather than the value.

quicksketch’s picture

StatusFileSize
new1.83 KB

Here's the patch I'm proposing. Note that check_plain() is preferred over strip_tags(), I'm just updating these calls while we're touching on this code.

quicksketch’s picture

Status: Needs review » Fixed

In my anxiousness to release 1.7 I went ahead and committed my previous patch. I tested it out and it works as long as the select key is an email address (not the value). Though you could simply have value only select lists and the email address will be used as both key and value, so it works in that case also.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.