9

I have the Webform 7.x-4.0-alpha6 version module enabled.

I have a Webform node with 20 form components. I added one email in Email Setting and I created the email template where I used the token: [submission:values].

Then I test the webform submitting a message. The problem is that [submission:values] print out the components values in a very plain way, no break line, no semicolon to make a difference between the title and the value for each component. Something like:

Name Jhon
Addresss Myaddress 12 
CP 19932
....

Having 20 component make the email completely unreadable

My question is: Is there a way (a token) to print them in a better way, at least adding a semicolon between the title and value, and making the title bold ? or putting the output in a table?

    Name: Jhon
    Addresss: Myaddress 12 
    CP: 19932

I know that I can print out the components in a separated way using the tokens: [webform:{component}-title] for the title and [webform:{component}-value] for the value

And then I can style them. But this is time wasting since I need all components to be shown in the email template

Update: I found this module but doesn't help me: http://drupal.org/project/webform_tokens

3 Answers 3

12

I haven't such problem, but I know, how to get special values from webform.

Webform tokens from submitted data. Includes the value and field label. Replace the "?" with the "Field Key". Append ":nolabel" for just the value.

So, you can use [submission:values:?:nolabel], where ? is field key of your component.

 Name: [submission:values:name:nolabel]
 Address: [submission:values:address:nolabel]

For me result is the same as for [submission:values]:

Name: Kate
Address: Moscow, Russia :)

Webform version: 7.x-4.0-alpha6 (7404).

Webform Tokens module is not needed.

Update

If you are using HTML mail, labels are outputted via theme_form_element_label and look like <label>Title</label>\n.

You can override webform-submission.tpl.php. Copy this file to the theme for rendering the emails from admin/config/system/mailsystem.
To add : I suggest just to modify render array:

if ($format == 'html') {
  foreach ($renderable as $i => $item) {
    if (is_array($item) && !empty($item['#title'])) {
      $renderable[$i]['#title'] .= ':';
    }
  }
}

print drupal_render_children($renderable);

But you can output substitutions fully yourself.

4
  • 2
    what you said is a valid option but I have to repeat this line set 20 times. I'm looking for a one line to output all the 20 components at once.
    – chefnelone
    Nov 9, 2012 at 10:18
  • @chefnelone I updated my answer.
    – kalabro
    Nov 9, 2012 at 12:16
  • I think you are close but... I just use the dpm function for the $renderable array and there is no $item['#title'] inside. Maybe you are on the webform version 3. I'm using version 4 beta6. Look my capture: content.screencast.com/users/chefnelone/folders/Snagit/media/…
    – chefnelone
    Nov 9, 2012 at 14:45
  • 1
    Your code is right. It is just I'm nesting the webform components and I will need to change this line if (is_array($item) && !empty($item['#title'])) { to make it work.
    – chefnelone
    Nov 9, 2012 at 15:12
1

Use Send e-mail as HTML option of webform.

This is available if you install the Mime Mail and Mail System modules, then go to admin/config/content/webform and set the Format to HTML.

0

Also note that if you're using a Grid component, you need to call that token with both the Field Key and then the question key. Grids are often used if you're doing a survey, for example and are asking people to rate something on a scale of 1-3, using radio buttons for each row, such as:

Sample Question:

Rank the following with 1=high, 3=lowest

+---------------+-----+-----+-----+
|   Breweries   |  1  |  2  |  3  |
+---------------+-----+-----+-----+
| Lighthouse    | [o] | [o] | [o] |
| Phillips      | [o] | [o] | [o] |
| Whistler      | [o] | [o] | [o] |
+---------------+-----+-----+-----+

To print out the value of just question 2's answer, you'd use:
Beer Question 2 value was: [submission:values:my_beer_field:phillips]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.