Closed (duplicate)
Project:
Webform
Version:
6.x-2.0-beta6
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2007 at 01:10 UTC
Updated:
10 Nov 2011 at 10:42 UTC
Jump to comment: Most recent file
Comments
Comment #1
quicksketchMarked http://drupal.org/node/162344 as duplicate
Comment #2
buddaIs this a candidate for use of the token.module ?
I'd also like to see such a facility.
Comment #3
jamiefifield commentedThis is exactly what I'm trying to figure out how to do (without editing templates and php code if I don't have to). Using 6.x-2.0-beta6.
Comment #4
domesticat commentedSubscribing.
Comment #5
CyberThijs commentedI would also like to see this feature come to webform! Subscribing
Comment #6
quicksketchMarked #308464: Include form data in email subject as duplicate.
Comment #7
quicksketchThe subject field already is automatically checked for tokens, however we'd need a set of tokens that contain the submitted values of the form as recommended in #300075: Introducing %value (previously %submitted) token to load submitted values.
Comment #8
domesticat commentedOut of curiosity, anything we could do to help this along? I'm starting to get more questions from my users as their usage of webforms increases.
Comment #9
quicksketchdomesticat, sure providing patches for this functionality is welcome. That issue I mentioned in #7 is more descriptive of how the solution should be implemented.
Comment #10
domesticat commentedI've still got to create the patch, but I dug through webform.module this morning and I think I see how to do it.
In version 6.x-2.3, edit webform.module as follows:
$email_subject = $node->webform['email_subject'];becomes
and then modifying a chunk of code starting at line 2024.
becomes
That last chunk isn't even strictly necessary, it seems; once the value of $email_subject is passed through _webform_filter_values(), there was existing code to do replacements based on %cid, but it just seemed a little ... non-intuitive to do it that way? I thought maybe supplying the option of using %webform[$fieldname] would make a lot more sense to non-programmers who didn't want to dig for the %cid for each field.
Is that really all that's required? Seems oddly simple. Maybe I'm forgetting something. Thoughts?
Comment #11
domesticat commentedA patch for the code idea in #10 is attached.
Edit: It looks like it works for referring to items by cid, as in %cid[6], but if the name of the field has a space in it, the %webform[] idea doesn't work right. Bah. Well, it's a start anyway.
Comment #12
quicksketchThis also isn't going to work with fieldsets or multi-page forms. We should be checking $form_state['values']['submitted'] for these values, not $_POST.
Comment #13
domesticat commentedYeah, I knew it was a nasty, quick kludge. Beat nothing, though. I always forget the multi-page forms part since I'm not using them. Hopefully I can re-examine it midweek.
Comment #14
wildebeest commentedSubscribing.
Comment #15
domesticat commented@quicksketch - I've come back to this patch request periodically and have tried to work out an elegant way of doing it, but every time I kept getting tangled up. I'm posting this in the hopes of triggering ideas in someone more capable than myself.
My first thought was to add in additional code to
_webform_filter_values()but I realized it only had access to$form_state['values']['submitted']. That gave me only numeric keys, and not the kind of friendly variable-name keys I know I'd prefer. I looked at calling more of the$form_statevariable and realized it seemed a bit redundant to provide it two separate times in arguments. I then went digging and rapidly realized the number of times I'd have to edit calls to this function across the entire module was higher than I expected -- and I didn't fully understand the implications of doing so, either. It bothers me to admit that I don't have time to figure out all of the pieces, but that's my reality right now.I started weighing the need to touch all of those separate parts of the code versus writing a single extra function that would work on just this single request. I'm posting this idea knowing full well that this isn't a particularly good way of getting this feature, but it's the best I have time to provide and I'm hoping someone else will pick it up and run with it.
The first replacement is a two-step one, kept from before:
$email_subject = $node->webform['email_subject'];becomes
Then this new function is added after the end of
_webform_filter_values():The first pass does the same level of substitution performed on the email body; the second gets me the tasty extra stuff. Using
$form_state['values']['submitted_tree']gave me a short and easy way to use strings like %webform['location'] in the subject line, which felt reasonably polished to me.I'm pretty sure this code is not the right way to go, so please understand I'm posting it with no expectation of seeing it committed. I recognize I can't give the module the time needed to rewrite all the little tendrils that affect
_webform_filter_values()but this, at least, solves the problem for me.Thoughts?
Comment #16
salmosri commentedi've been playing around with this solution, i have used standard forms with nothing too complex, and it works a charm, and i would say very elegantly. i can't say i have stress tested it, but for simple implementations it works a treat :).
Cheers,
Shadi
Comment #17
marcvangendsubscribe
Comment #18
tommyk commentedThanks for the work on this. I'll be glad when it makes it into the module.
Comment #19
jeffschulerMarked #352437: Using webform variables with in the from field and subject and feature request. as duplicate.
Comment #20
aether commentedIt would appear that the seeds of this functionality are in the 6.x branch but appear to be undocumented (and likely unsupported) at the moment. I was able to create a custom email subject using user submitted values the following way:
1. Add a new form component of the type "hidden". Let's call it "Email subject".
2. Using the desired email subject in the original post for this issue as an example, in the default value field for this component enter:
Event enquiry from %cid[x] for %cid[y] in %cid[z]
The x, y, and z keys above should represent the component id numbers (cid) relating to the form's component fields for "name", "eventdate", and "city" (Hint: you can find the cid for a form component by mousing over it's Edit link in the table on the "Form components" page and noting the last argument in the link's url). It seems that %cid is set up in the module as a token for the array of the form's submitted values.
3. Choose "Email subject" in the Component drop-down for the E-mail subject setting on the webform's Configuration page.
Naturally, this same technique will work for the "Email from name" and "Email from address" settings as well.
Comment #21
sinigur commentedI just tested out #20 and that worked. Good enough for me.
Comment #22
john bickar commentedConfirming that the method in #20 works for me as well in 6.x-2.7.
Great usability improvement - thanks!
Comment #23
tommyk commentedThe method in comment #20 will not work if the component is a select field with multiple values set as the option. The word "Array" is returned instead of any of the text of any of the options selected.
Does anyone know of a workaround?
I'm trying to make the subject of the emails contain the text of one or more of the options selected. It's not that big of a deal, but it'd be nice.
Comment #24
Marcus Aurelius commentedI have the same problem, I want a reservation date to be shown on the subject line. The %cid[] gives me "Array". I have found the field "no" in the table webform_submitted_data to point to a part of a field. So I tried almost every combination of %cid[] and %no[], but nothing works. I guess a patch will be necessary for this. Any progress on that?
Comment #25
Marcus Aurelius commentedI have the same problem, I want a reservation date to be shown on the subject line. The %cid[] gives me "Array". I have found the field "no" in the table webform_submitted_data to point to a part of a field. So I tried almost every combination of %cid[] and %no[], but nothing works. I guess a patch will be necessary for this. Any progress on that?
Comment #26
elijah lynn#20 was very helpful.
For the noobs like me who are wondering if %cid[x] means %cid8 or %cid[8], I will save you a step, it is the latter!
%cid[8]
That would be correct. Not sure what these guys are talking about for arrays though.
Comment #27
quicksketchLet's consolidate this with #300075: Introducing %value (previously %submitted) token to load submitted values.
Comment #28
prophet108 commentedAether. Thanks for this solution!
Comment #29
pieterbezuijen commentedAether: Many thanks for this solution!
Comment #30
clintcar commented#20 does work, but for (select) you do get the ARRAY error in the subject line. I was able to change my settings to "List box" and cleared this up as a work around. Wouldn't help if i wanted users to select more than one option, but it might get around this error for some until fixed. Thanks Aether!
Comment #31
jeffschulerA note for those using Webform 3:
Using %cid[x] no longer worked when I upgraded to Webform 6.x-3.0-beta5 (from 6.x-2.x.)
However, using %value[fieldkey] -- as described in #300075: Introducing %value (previously %submitted) token to load submitted values -- did work.
Comment #32
sense-designA comment / description should be added below the subject field, like it is within the "E-mail template" fieldset.
Comment #33
machete1 commentedPer Post #31 -
I have a text field in my webform with Field Key project. This field is also the first component I created for the form so it's cid is 1.
In the Custom Subject field for email submission, I tried using %value[project] and %value[1]. In both instances, I received the %value[project] (or [1]) in the email subjects received.
Can someone explain what I am doing wrong?
Comment #35
jeffschuler@machete1: what version of webform are you using?
Using %value[key] is working fine for me with 6.x-3.9.
Comment #36
machete1 commented@ jeffschuler:
I am using 6.x-3.9 as well.
To confirm a couple things:
-- You actually type the brackets [ ] correct?
-- Where you have the word key in your example is that a number (cid) or the Field Key name?
I just want to make sure that I am not having an oblivious moment of stupidity.
Thanks Jeff!
Eddie
Comment #37
ejohnson commentedAny suggestions on what I'm doing wrong? Running Webform 6.x-3.14
In the E-mail subject - Custom field, I've tried:
Customer Number: %cid[19]
Customer Number: %cid[customer_number]
Customer Number: %value[19]
Customer Number: %value[customer_number]
19 being the component ID when hovering over the Edit link
customer_number being the Field Key
Can anyone be more clear on what to enter?
Thanks.
EDIT: Due to the fact that it was a nested field with a fieldset, I had to use:
%value[service_address][customer_number]
Comment #38
joran lafleuriel commentedthanks ejohnson
Your solution in #37 saved me !
Tokens for values in fieldset must mention the fieldset