i was searching and reading all issues and forum topics, tried a lot of available code but no success.
seems that functions logic is not very clear for me, which is ok as i am not a php developer.
anyway, my goal is to display form results upon submitting in printable way, i.e. user is able to print just submitted form.
i found some solution in mail formatting but i really need to format text in different way (since huge number of form fields and specific theme ...) .
so, if i would know to return and display single value i could do it with all the rest and will be able to format/display it in required way.
also, for example _webform_submission_format function doesn't display values of file field (upload) and i would like to display name of the uploaded file (doesn't have to be download link, just displayed file name) ...
any suggestions and help would be much appreciated, thanks !
here is the latest code i tried to put in additional processing to get just email field name and value, no success :(
foreach ($form_values['submitted'] as $field_id => $value) {
$component = $node->webformcomponents[$field_id];
if ($component['name'] == "email") {
$email = $value;
$out = $component['name'] . ":<b> " . $email ."</b>";
}
}
print($out);
Comments
Comment #1
Critical Tinkerer commentedThere seems to be no proper treatment of the tags "Additional Validation" and "Additional Processing" in any documentation. I, for one, would like to see some sample code that does just this sort of thing and a whole slew of other things.
The module itself says:
Enter PHP code to preform additional validation for this form. Include the < ? php ? > tags. $form_id and $form_values are available variables. If validation fails, use the form_set_error function to prevent the form from being submitted. Use the same syntax as a _validate function used in the Forms API.
This doesn't help anyone just getting started. How about a handbook on advanced WebForm usage?
Comment #2
quicksketchWalk the walk:
http://drupal.org/node/add/book/parent/22361
Comment #3
quicksketchSome useful issues:
Advanced validation and submission code: http://drupal.org/node/81761
Setting custom confirmation messages/pages: http://drupal.org/node/131396
Comment #4
quicksketchComment #5
quicksketchI figured this out today by accident and I thought I would share the solution.
Use the following PHP code as the Confirmation message for your webform:
This will print out the display of the submission on the confirmation page.
Comment #6
seakayjay commentedI'm looking forward for this as well. Instead of display of submission, is there anyway to display a single field value only on the confirmation page?
Regards
Comment #7
john.money commentedtag for later... I've got some examples and if I can find the time between projects to write them all up, I will. To get you started, here is some code I used just tonight that will throw an error if two email fields email_address and email_verify are not the same:
Comment #8
FredJones commentedI also want this, to be able to style the output and show the user the data he inputted. I see no way except via PHP/MySQL. You would have to parse the URL to get the sid # and then extract the submitted values from the webform_submitted_data table using that sid.
Quite a roundabout way however...
Comment #9
FredJones commentedJust in the event that anyone is really reading this, I do now see that you can also get the sid value from $_REQUEST. Try
and see. :)
OK, I am done. I just coded a custom contact us page in plain old PHP and it shows the data inputted by the user very nicely. Simple, yet works perfectly.
Comment #10
rick hood commentedThe code mentioned above works great:
My problem comes when the form element is a multiple choice check box (multiple selections allowed). The $value then seems to be an array and so what prints is just "array".
I probably need to loop through that array to get the values and concatenate them together?
I'm afraid I either don't know enough PHP and/or Drupal to understand what I need to do this. I know this is probably basic.
Thanks for any advice.
More info:
A
print_r ($node)for the actual webform element I am working on looks like this for one of the multiple choice checkbox elements:So, say the user chose the first two: T29C and T29R. I would want to those to appear together in the output that prints the submitted value of that element.
I should note that this is NOT for use on the confirmation page, but rather to use these values in an email that gets sent - but either way, I need to grab the values.
Comment #11
quicksketchHey Rick, like you mentioned, if the value is an array, you'll need another loop inside to add all the strings together. Here's an untested attempt at what you might be wanting. Hope this helps!
Comment #12
rick hood commentedNate - thanks a lot - that worked!
But I don't fully understand why it works. The part that gets me lost is in this line:
where I don't fully understand what these are: $value, $key and $choice.
My guess is:
$value is an array, because this form element is multiple-select, unlike the other single-select form elements where $value is just one number or string.
$key is the key of the array - OK so far so good I guess...
$choice is the value of each key - but why $choice? I don't understand how one knows that $choice the the variable to use here.
And in the first foreach statement:
It's a mystery to me how one knows to use $form_values['submitted'], $field_id and $value - as those are not things you see by just doing a
This is the kind of situation where I get stuck with Drupal, and I need to somehow get better at that as it seems key to really understanding Drupal.
But anyhow - thanks so much for your help!
Comment #13
zaphod280380 commentedSorry but i can't understand where i have to put this code (i additional processing field) and how to change it with my form name. Help!
Comment #14
zaphod280380 commentedSorry but i can't understand where i have to put this code (in additional processing field?) and how to change it with my form name. Help!
Comment #15
quicksketchClosing to clean up the issue queue.
Comment #16
drein commentedI'm not a programmer, and I'd like to have a sort of reports or data printed when the user click the confirm button.
I don't understand what code should I insert... I tried copy/paste some codes of this thread but no lucky...
any help?
Comment #17
fido100 commentedThis doesn't seem to work in Drupal 6.5 and the latest version of webform. Do you have updated code that would work?
I am trying to implement a system whereby I can pass simple variables such as first_name and last_name to an ecommerce service. I thought this might be an easy thing to accomplish but I can't get anything to show up on the confirmation page.
With thanks
James
Comment #18
jtjones23 commentedI'd also like to show the results of a webform submission to the user. The code from #5 displays the form but not the input.
Drupal 6.8
Webform 6.x-2.3
Comment #19
saml commentedI managed to display the submitted data on the confirmation page now (Drupal 6, Webform 6.x-2.6).
I followed the instructions in modules/webform/THEMING.txt to copy the file webform-confirmation.tpl.php from modules/webform to my theme folder.
Then, inside that file, I use this code to load the submitted data from the database:
($sid (submission id) and $node->nid are available in this context.)
Then I used the following to see how to retreive the values I was interested in:
Note: $temp_submission will be an object, not an array, so the first level of elements that you see in the tree outputted by print_r is variables in that object, and are accessible with the "->" syntax. So, to use the content of an e-mail field (no 2 in my form) in a message, I used:
Hope this helps.
Comment #20
sunchaser commentedgood stuff.
is this still valid code for versions 3.x ?
Comment #21
meerkat commentedYes.
Comment #22
todderasesareddot commentedComment #23
syntheticMedia commentedIm happy to report #19 works well with 6.3, thanks for the tip.
Comment #24
vj2150 commented#19 works for 7.57 as well. Thank you. Your post is helpful for newbies like me.