If I have a text field on the form and someone enters '0' (a zero without quotes) for that field, then '0' will not be displayed for that field when the custom email template contains:
%email_values

It displays as:
test field: (no value displayed)

When it should display as:
test field: 0

But putting %value[test_field] in the template does display correctly as:
'0' (no quotes).

This is easy to replicate.

Comments

druderman’s picture

The problem is in theme_webform_element_text() at this point $value is '0' which evaluates to false.

// Add the value to the output.
  if ($value) {
    $output .= (strpos($value, "\n") === FALSE ? ' ' : "\n") . $value;
2  }

One quickie workaround is to change it before it's rendered. Alternately, I could have recreated most of the code in my theme function. The real fix is to check if $value === 0.

/**
* Work-around to force webform to show ' 0 ' when text value is '0'.
*/
function MYTHEME_webform_element_text($variables) {
  $value = $variables['element']['#children'];
  if (trim($value) === '0') {
    $variables['element']['#children'] = ' 0';
  }
  // Call the default theme function if there is a value.
  return theme_webform_element_text($variables);
}
liam morland’s picture

Version: 7.x-3.18 » 7.x-4.x-dev
Status: Active » Needs review
StatusFileSize
new351 bytes

Here is a simple patch that fixes this issue.

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new508 bytes

Hi guys, thanks for the report. I'm not sure what the purpose of that conditional is for at all. Seems like the whole statement could just be deleted. I've committed this patch. Thanks!

Status: Fixed » Closed (fixed)

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