Attached to this post is a module called webformtokens. This module uses the tokens module to expose as tokens the values submitted to the webform by the current user.

For example, the fillpdf module makes PDFs based on the token values of a given node. With webformtokens installed, fillpdf can make PDFs using the values submitted to a webform.

webformtokens currently only exposes the values from the user's first submission.

(I have many years of experience in PHP, but I am new to Drupal. My apologies if I miss some Drupal design conventions.)

CommentFileSizeAuthor
webformtokens.zip2.98 KBLiam Morland
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liam Morland’s picture

Tokens are generated by this module in this form:
[webform-val-form_key]

form_key is configured in Webform under the Advanced settings for each form component.

For example, a typical form might result in these tokens:
[webform-val-name_first]
[webform-val-name_last]
[webform-val-age]

For form components of type grid or select, the tokens contain the safe_key. An additional token is generated with the readable option:
[webform-fullval-form_key]

In addition, the metadata that comes with each submission is exposed as the following tokens:
[webform-meta-nid] Node ID of the form
[webform-meta-sid] Submission ID of this submission
[webform-meta-submitted] POSIX timestamp of the submission
[webform-meta-remote_addr] IP address of the user submitting the form
[webform-meta-uid] User ID of the user submitting the form
[webform-meta-name] Name of the user submitting the form
[webform-meta-status] Form status

The above list is not hard-coded. If webform_get_submissions returns other properties, they will appear as tokens.

davidw’s picture

Thanks for the code! I am having trouble getting this to work though. (Most likely because I don't have a real good understanding of how tokens work)

Here is what I have done:

1. I have created a simple webform using webform with webformtokens installed.

2. I have fillpdf installed and have deployed the iText servlet using Apache Tomcat 5.5
I am able to generate fields from my PDF's with no problems.

3. When I edit the fields generated, I get stuck. In the "Value" field, (according to the fillpdf docs) I should enter any of the tokens from the list at the bottom of that page. I don't see the tokens that I need.
I have read your documentation, but I am confused. Should I see the tokens in the list? If not, I don't understand what to enter in the "Value" field.

Anyone?

Liam Morland’s picture

The Webform tokens will not show up on the FillPDF configuration page, since they don't exist at that point.

The token names are like this:

[webform-val-form_key]

Replace "form_key" with the form-key of the Webform element.

quicksketch’s picture

Version: » 6.x-3.x-dev
Status: Needs review » Closed (won't fix)

This won't be added directly to the Webform project, but feel free to apply for a CVS application and start a separate project for this code.

rougekris’s picture

You've fixed my problem with FillPDF! Thank you very much!

Nimo’s picture

The function webform_get_submissions() doesn't seems to exist in webform-6.x-3.6.

This module seems to be exactly what I need but at the moment it produces an php error message about undefined function (webform_get_submissions())

wizonesolutions’s picture

Was this never made into a proper Drupal project? I'm going to do so myself soon once I get around to supporting Webform tokens in Fill PDF 7.x-1.x. It should be its own module so the wider community can benefit.

davidw’s picture

@ wizonesolutions - I think that's a great idea !!

I was never able to get this to work properly for my application.

Liam Morland’s picture

@wizonesolutions: I have now moved the existing code into a sandbox project.

@davidw: I understand that the code does not work with recent versions of Webform, perhaps starting with version 3. I may at some point have time to fix it. In the meantime, you could use an older version of Webform.

davidw’s picture

@Liam Morland: Thanks for the info!
Maybe that's been my problem. I'll try the 2.10 version of Webform.

jsheffers’s picture

@Liam Morland

Oh no did this module ever get updated to work with webform 3.11? I have two major applications that are using FillPDF and I just updated to Webform 3.11. Please say yes...

Liam Morland’s picture

I don't think so, unfortunately. If you are using Drupal 7, there is a development version for that and I think it works with later versions of Webform. See the Webform Tokens project.