I can’t seem to find a lot of documentation on certain Drupal modules. Yet another thing about Drupal that is frustrating, especially considering how much crap people throw at WordPress. WordPress seems to be much more organized and JUST as capable as Drupal. Oh well. Haters gonna hate.
THE FOLLOWING DESCRIBES HOW DRUPAL 6 WORKS.
THIS HAS CHANGED A BIT FOR DRUPAL 7.
(See comments for info about Drupal 7.)
How to customize the subject line in an automated email generated by the Drupal webform module
Sometimes examples save a lot of descriptive verbiage…
field label “First Name” – field key “fname” – webform email custom subject line “Message from %value[fname]”
and
field label “Last Name” – field key “lname” – webform email custom subject line “Message from Mr. %value[lname]”
unless the field in question is contained in a fieldset element! If that’s the case:
field label “First Name” – field key “fname” – fieldset field key “contact_info” – webform email custom subject line “Message from %value[contact_info][fname]”
and then click “Save e-mail settings” and you’re done!
This information was derived from the last comment on this page: http://drupal.org/node/823408 after 45 minutes of looking through a bunch of dead ends. I hope this post is easier to find, digest and get back to what you were doing before you forget why.
Mark Housel asks, “I was wondering if you could tell me just where these few lines go?”
So, the above details do take for granted that you know where the text in question should be input into the Drupal system. I generally try to avoid doing that. So many great how-tos on the web are written by smart people that seem to be talking to other people that already know a great deal about the subject in question. So we should all try to account for folks that are not familiar with certain details.
Mark and anybody else that is a little lost: I assume you know how to create a webform node on your Drupal site. If you click to edit the webform node in question you should see something like this:
- From the Webform node > edit window, click the “Webform” tab (see A)
- Click on the “E-mails” sub-tab (or section … whatever you want to call it … see B)
- If there is an existing E-mail output setup, click “Edit”. If one does not exist click “Add”
Following steps 1 thru 3 will bring you to the following page:
Scroll down to the “E-mail header details” and the “E-mail subject > Custom”. This is the input that I am referring to above. Enter what you need to there to alter the subject line of the automated email output.
Let me know if there are any other questions.
Hi,
Since I am trying to just what you describe, allow the subject field to be something more descriptive than “Form Submission from: Contact Us”.
If it could be somehow related to the sender of the contact it would make it better.
I was wondering if you could tell me just where these few lines go?
I truly haven’t a clue, and if I can’t do something through the web (GUI) interface I have exactly ZERO idea of how it can be done.
Thanks,
Mark
Please note that the token system has now changed in D7
i.e.
Token System Replaced with D7-style Tokens
http://drupal.org/node/1609324
So instead of %value[$key]
it should be now
[submission:values:$key:nolabel]
e.g.
[submission:values:first_name]
returns:
First Name: Sally
or
[submission:values:first_name:nolabel]
returns:
Sally
I was attempting to use the %value[$key]
where only %value[$key] was returned
i.e. it was not parsed.
@Steven Thanks for this info about the changes in Drupal 7! I will try to get around to updating the post, but until then your comments are a pretty clear description of how it works.
Hi All,
a slight but important amendment to my previous post.
The change token change is not related to Drupal core
but to the version of Webform.
In D7 I downgraded to Webform 3.x from Webform 4.x Alpha
and noticed the change in the key structure.
So to summerize, if one wanted to customize the subject like
one could do the following:
Webform 3.x
%value[key]
e.g.
My Form Submission – %value[some_comment]
or if the field is nested in a fieldset then:
My Form Submission – %value[customer_details][some_comment]
Webform 4.x
[submission:values:$key:nolabel]
e.g.
A comment – [submission:values:some_comment:nolabel]
or if the field is nested in a fieldset then:
A comment – [submission:values:customer_details:some_comment:nolabel]
Apologise for the confusion
I am having trouble with getting the component email address in the E-mail from address. What do I put in custom? I keep getting an error. I have tried everything such as %value[email] etc.