I have been trying to accomplish the following, and after doing a search and finding 1 thread with the exact issue I am recieving, it had been closed so I though I would try a more direct approach since its been a week or two and hoping someone can verify what I have done, or what I need to do to make this work....

Here was my question/issue, located at: http://drupal.org/node/347361

Hey there,
I am trying to accomplish this as well (empty fields to be excluded in the form email). After editing my drupal/modules/webforms/webform-mail.tpl.php I am still getting empty fields sent in my emails. Here is what I have done:

Edited the drupal/modules/webforms/webform-mail.tpl.php file to read:

<?php
// $Id: webform-mail.tpl.php,v 1.1.2.5 2009/11/06 00:59:47 quicksketch Exp $

/**
 * @file
 * Customize the e-mails sent by Webform after successful submission.
 *
 * This file may be renamed "webform-mail-[nid].tpl.php" to target a
 * specific webform e-mail on your site. Or you can leave it
 * "webform-mail.tpl.php" to affect all webform e-mails on your site.
 *
 * Available variables:
 * - $form_values: The values submitted by the user.
 * - $node: The node object for this webform.
 * - $user: The current user submitting the form.
 * - $ip_address: The IP address of the user submitting the form.
 * - $sid: The unique submission ID of this submission.
 * - $cid: The component for which this e-mail is being sent.
 *
 * The $cid can be used to send different e-mails to different users, such as
 * generating a reciept-type e-mail to send to the user that filled out the
 * form. Each form element in a webform is assigned a CID, by doing special
 * logic on CIDs you can customize various e-mails.
 */
?>
<?php print t('Submitted on @date', array('@date' => format_date(time(), 'small'))) ?>

<?php if ($user->uid): ?>
<?php print t('Submitted by user: @username [@ip_address]', array('@username' => $user->name, '@ip_address' => $ip_address)) ?>
<?php else: ?>
<?php print t('Submitted by anonymous user: [@ip_address]', array('@ip_address' => $ip_address)) ?>
<?php endif; ?>


<?php print t('Submitted values are') ?>:

<?php
  // Print out all the Webform fields. This is purposely a theme function call
  // so that you may remove items from the submitted tree if you so choose.
  // unset($form_values['submitted_tree']['element_key']);
  if (!function_exists('webform_empty_fields')) {
    function webform_empty_fields(&$form_values) {
      foreach ($form_values as $key => $value) {
        if ($value == '') {
          unset($form_values[$key]);
        }
        if (is_array($value)) {
          webform_empty_fields($form_values[$key]);
          if (empty($form_values[$key])) {
            unset($form_values[$key]);
          }
        }
      }
    }
  }

  webform_empty_fields($form_values['submitted_tree']);

  print theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node);

?>

<?php print t('The results of this submission may be viewed at:') ?>

<?php print url('node/'. $node->nid .'/submission/'. $sid, array('absolute' => TRUE)) ?>

Let me know if I can provide any more information. Any help would be greatly appreviated. Thanks in advance!

Comments

quicksketch’s picture

Status: Active » Closed (won't fix)

Unfortunately since that last issue, I have modified the policy within the Webform issue queue and I'm no longer providing any support when doing custom code or theming (as you may have noticed when you created this issue).

quicksketch’s picture

Also, please don't open duplicate issues just because you're not getting an answer in the original. #347361: empty fields not to be included in e-mail.

ryndog’s picture

I must appologize as I am still new to this community and learning the ropes, but thank you for your response. Great module and thank you for the hard work you have done :)