Is just me or the display of submitted form values in the generated e-mail is plain broken in 1.4 release ? :-)
It is anyway when you have the habit to give your components a textual value for 'form_key', instead of the default cid.

Attached is a fix that is probably more of a suboptimal hack, but seems to at least do the trick.
Patch is against -dev

webform.inc_.patch892 bytesyched
Members fund testing for the Drupal project. Drupal Association Learn more


quicksketch’s picture

Thanks as always yched :)

I'll see if I can come up with a cleaner solution, but this points me in the right direction.’s picture

+1 on patch... works for me too. There appears to be an extraneous line that is getting passed from $form_values['submitted_tree'], but I can live with it. Maybe the submit value??

yched’s picture was marked duplicate, but has a different patch.

I guess we'll let you pick, quicksketch :-)

pulpzebra’s picture

patch provided seems to insert into message body N x N fields (where N is the Number of fields of the webform). That is, if my form is e.g. Name, Company, Address in the email body I actually see:


Trying to look at the code I see that

@@ -205,36 +206,47 @@
   return $message;
-function theme_webform_mail_fields($key, $value, $node, $indent = "") {
-  // First check for component-level themes.
-  $themed_output = theme("webform_mail_". $node->webformcomponents[$key]['type'], $value, $node->webformcomponents[$key]);
-  if ($themed_output) {
-    // Indent the output and add to message.
-    $message .= $indent;
-    $themed_output = rtrim($themed_output, "\n");
-    $message .= str_replace("\n", "\n". $indent, $themed_output);
-    $message .= "\n";
-  }
-  // Generic output for single values.
-  elseif (!is_array($value)) {
-    // Note that newlines cannot be preceeded by spaces to display properly in some clients.
-    if ($node->webformcomponents[$key]['name']) {
-      // If text is more than 60 characters, put it on a new line with space after.
-      $long = (strlen($indent . $node->webformcomponents[$key]['name'] . $value)) > 60;
-      $message .= $indent . $node->webformcomponents[$key]['name'] .":". (empty($value) ? "\n" : ($long ? "\n$value\n\n" : " $value\n"));
+function theme_webform_mail_fields($form_values, $node, $indent='  ') {
+  $key = '';
+  foreach($form_values as $field_key => $value) {
+    // First figure out actual key...
+	  foreach($node->webformcomponents as $k => $v) {
+	    if ($node->webformcomponents[$k]['form_key'] == $field_key) {
+	      $key = $k;
+	      break;
+	    }
+	  }
+    // First check for component-level themes.
+    $themed_output = theme("webform_mail_". $node->webformcomponents[$key]['type'], $value, $node->webformcomponents[$key]);
+    if ($themed_output) {
+      // Indent the output and add to message.
+      $message .= $indent;
+      $themed_output = rtrim($themed_output, "\n");
+      $message .= str_replace("\n", "\n". $indent, $themed_output);
+      $message .= "\n";
-  }
-  // Else use a generic output for arrays.
-  else {
-    $message .= $indent . $node->webformcomponents[$key]['name'] .":\n";
-    foreach ($value as $k => $v) {
-      $message .= theme('webform_mail_fields', $k, $v, $node, $indent ."  ");
+    // Generic output for single values.
+    elseif (!is_array($value)) {
+      // Note that newlines cannot be preceeded by spaces to display properly in some clients.
+      if ($node->webformcomponents[$key]['name']) {
+        // If text is more than 60 characters, put it on a new line with space after.
+        $long = (strlen($indent . $node->webformcomponents[$key]['name'] . $value)) > 60;
+        $message .= $indent . $node->webformcomponents[$key]['name'] .":". (empty($value) ? "\n" : ($long ? "\n$value\n\n" : " $value\n"));
+      }
+    }
+    // Else recurse for arrays.
+    else {
+      $message .= $indent . $node->webformcomponents[$key]['name'] .":\n";
+      foreach ($value as $k => $v) {
+        $message .= theme('webform_mail_fields', $value, $node, $indent ."  ");
+      }

At the very bottom there is a foreach on each $value, while the collect of each webform field should be already done at the head of the new function.

It works for me by replacing

+ foreach ($value as $k => $v) {
+        $message .= theme('webform_mail_fields', $value, $node, $indent ."  ");
+      }


+        $message .= theme('webform_mail_fields', $value, $node, $indent ."  ");
phoolish’s picture

Patch seems to work great. I also noticed that the default email subject doesn't seem to be sent. Instead it defaults to the none selection. I commented out starting at 1378 of location.module.

if (strcmp('none', $node->email_subject)) {
  $email_subject_string = '';

That seems to solve the problem.

scor’s picture

This particular issue with the strcmp has been reported 3 times already. Here is the main thread :

yhager’s picture

+1 for the yched patch. This really should be included in the release ASAP, since IMHO it's a basic feature of this module.

BarisW’s picture

This patch doens't really work well.

It only submits the values of the last page, if you use the BREAK element.

yhager’s picture

It only submits the values of the last page, if you use the BREAK element.

I assume you mean 'emails' instead of 'submit'. If this is the case, then it is still better than what we have today, which seemed (to me after first impression) that this module is totally broken.

yched’s picture

Well, let's not dramatize, it's not *totally* broken. This is simply one (important) feature that is not working.

@Sixcolored : it's quite possible that my patch misses some stuff. AAMOF, even besides the issue you're mentioning, I am pretty sure it is not the proper way to fix that (suboptimal). It's only a share of the quick'n dirty hotfix I figured to make it work as I need it to.

dquakenbush’s picture


HorsePunchKid’s picture

Status: Active » Needs work

Subscribing. This patch is working well for me, in conjunction with the strcmp patch. I'm not using breaks, but as has been said, this patch is at least an improvement over "not working at all". :-)

Periander’s picture

Title: E-mail contains no form values » Thanks

Thank you very much, this patch has fixed my issue with the problem.

Being a Drupal newbie, I struggled at first to realise where to start as far as adding this code went. However, for others in my boat I feel I should note, you simply need to highlight the lines that have a minus symbol '-', (line 231 in in my case, but mentioned as line 232 in the code, so maybe I have a *slightly* different version), and then paste in all the lines with pluses next to them, '+', (and remove the pluses, and fix up your spacing/tabs to neaten it up).

scor’s picture

Title: Thanks » E-mail contains no form values
richardroth’s picture

Tried it and after several attempts, I finally got it working! Great job yched!

RoloDMonkey’s picture


I noticed that this patch turns my State drop-down list value of CT to ct in the email.

I use this module on a lot of sites. I hope this can be fixed soon.

GoofyX’s picture


RoloDMonkey’s picture

This patch also does not fill in the default subject, "Form submission from: $title" in the email.

solutionsphp’s picture

This patch doesn't seem to work for me. Drupal 5.2.

My webform-generated emails were not displaying the email subject or the form fields and data in the email body.

I applied this patch to fix the email subject line issue, and it worked fine:

Next, I applied the patch from this thread, and now instead of seeing:

Submitted values are:

in my emails, I simply see:

Submitted values are

Colons are missing as well as data now!

There are numerous threads about this issue and all of them seem to go off in a different direction. Can we get a single support thread started that posts the correct patches for BOTH the blank email subject line and body consolidated into one, easy-to-understand thread?

sstacks’s picture

Just confirming this patch did fix my issues with the form fields not showing up in the email.

I still have the issue of a blank subject line, which seems addressed in other areas.

I am on Drupal 5.1.

HeinzS’s picture

Just change this simple in (or copy function to your own theme):

function theme_webform_create_mailmessage($form_values, $node, $sid) {
//  $message .= theme('webform_mail_fields', '', $form_values['submitted_tree'], $node);
// Line 183 change "submitted_tree" to "submitted"
  $message .= theme('webform_mail_fields', '', $form_values['submitted'], $node);

Thats all.

solutionsphp’s picture

Changing line 183 didn't work for me. I still see just:

Submitted values are

in the resulting email. Any other ideas for howto output the form data in the email?

dquakenbush’s picture

Do you really need custom keys?
After fighting with this for a while I recreated my forms, and just used the field keys generated by the module. You can change the label, but don't touch the key. To get the subject I added a hidden field, then selected it in the appropriate drop-down. Worked like a charm on a number of different fairly complicated forms...

snickerbee’s picture

Ditto for me dquakenbush. If you use the auto generated keys then the email feature seems to work correctly. After submission though, I only get a blank page. I am struggling to get the correct page to appear after submitting the form.

Anybody got this figured out?


dquakenbush’s picture

I use a lot of local redirects -- seemed to work as expected out of the box.

In the "Confirmation message" box I disabled rich text and put internal:local/path/to/file ...

mo6’s picture

Is there any progress on this bug? Can we expect a new release anywhere soon?

mo6’s picture

The patch works partly (D5.2): fields containing an ampersand (in particular select fields with options containing an ampersand) are not mailed.

mo6’s picture

The fix suggested in #21 works in D5.2. Only fields with ampersands are not mailed as noted in #27, I suspect this is a different issue.

coupet’s picture

Version: 5.x-1.4 » 5.x-1.x-dev

confirm: receiving blank email
The csv results are OK.

Email message follows:
Submitted values are:

Note: Drupal 5.2 @ Webform 5.x.-1.x-dev on Sept 12 , 2007

mo6’s picture

@coupet: what's your experience with 1.4 with #21 applied?

mennonot’s picture

+1 on the patch in comment #21 which worked for me. However, I found that it didn't work to select to use [default] options for "E-mail from name:" and "E-mail from address:" and "E-mail subject:" fields. Instead I had to create hidden fields in the form and use those to populate the 3 of them. I don't know if this is related to the original bug or not.

Also, though the form values are coming through, I also get this at the end of the email:

Submitted values are:
mo6’s picture

coupet’s picture


// $message .= theme('webform_mail_fields', '', $form_values['submitted_tree'], $node);
$message .= theme('webform_mail_fields', '', $form_values['submitted'], $node);

works now as per post 21, but the latest dev version 'submitted_tree' is only mentioned in line 187

steveoliver’s picture

Title: E-mail contains no form values » Redirection not working

Redirect values "interal:contact_us/qsuccess.php" or "http:///contact_us/qsuccess.php" do not work to redirect after submit.. Webform emails the results, but doesn't redirect the visitor... any ideas?

mo6’s picture

Title: Redirection not working » E-mail contains no form values

Please don't hijack this issue, you can file a new issue for your problem.

arbel’s picture

#21 worked for me great!

had Submitted values are:
with no : after or anything.

and now it works great.


lenart’s picture

The patch (#0) worked for me (Drupal 5.1, webform 1.4).

I tried and applied patch #21 (changed submitted_tree to submitted) but didn't work for me so I changed it back.

Thanks guys.

budda’s picture

I applied and get most of the expected results in my emails.

neurojavi’s picture


# 21 works for me (version 5.x-1.4)

Many thanks.-

AndrewJarvis’s picture

Yes, #21 was what fixed it for me - just that one little change from "submitted_tree" to "submitted" only mine says it's line 187, not 183.


When will this fix be included in the current version of the module? Or is it now?

David Lesieur’s picture

Status: Needs work » Reviewed & tested by the community

Patch #21 seems to work. Let's dare mark it as RTBC and see what happens. ;-)

harryma’s picture

line 183 fix worked perfectly!! been banging my head on a fix , the theming instructions did not work at all for me.

drupal v.5.2

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

I've applied #0, as I believe this is the correct fix. Those that have applied #21, it only works adequately for those people that do not use fieldsets and nested fields. In those cases, the output isn't nicely indented or in the correct order. I'll release a new version of webform soon, as this problem has been plaguing users since 1.4's release. Thanks to everyone for their feedback.

Anonymous’s picture

Status: Fixed » Closed (fixed)
darumaki’s picture

is the first attachment a correct fix for the latest version ? I don't recognize any of it within the current webform, inc

getting confused more and more as I read all the various issues, so far I have not been able to get it to send anything

RoloDMonkey’s picture

As far as I know, this was fixed in version 1.7. You do not need to apply the patch to version 1.7.

I just upgraded to 1.7 this week and it seemed to work fine. This ticket is closed. If you are having trouble sending email, please open a separate ticket.

druvision’s picture

Version: 5.x-1.x-dev » 5.x-1.8
Priority: Normal » Critical
Status: Closed (fixed) » Active

In my website, webform still sends blank email bodies, in all versions.
See detailed description here:

Rowanw’s picture

Status: Active » Closed (fixed)

Use the other issue that you already created, don't reopen closed issues.

Rick at Monarch’s picture

Just an FYI. I added webform reports and my similar problem disappeared.

Rick Nashleanas