Hi there

Maybe I am missing something obvious here but...

I have successfully uploaded a document template, and that document is indeed what is served up when the form is submitted.

However, I can't even get a text token to work, let alone an image token!

In my document template, I tried including this:

[submission:values:first_name]

where first_name is the field key of a field on the webform

and when the document is served up, there's no substitution happening.

what am i doing wrong?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

goatvirus created an issue. See original summary.

rafenden’s picture

Hi goatvirus,
please upload and example docx file.

earthangelconsulting’s picture

FileSize
3.35 KB

here's my docx file (in zip format, this website wouldn't allow a file of type docx)

earthangelconsulting’s picture

hello @rafal.enden does that uploaded file throw any light on why this isn't working for me?

Kwaailappies’s picture

FileSize
10.75 KB

Hi,

My Document is a docx but also doesn't replace tokens with values I have tried all sorts of token format, please help me.

rafenden’s picture

goatvirus, I tried your docx file and it worked well.
Could you please tell me what components in webform do you have?
Is the file downloaded correctly?

Kwaailappies, you are using tokens in format for Webform 3.x.
Please change the tokens to be something like:
[submission:values:first_name] or [current-user:name]

areynolds’s picture

One potential error I've noticed that could be causing this issue:

I noticed that, after submitting my first form and having the substitutions work, all subsequent form submittals returned a docx file that had the same substitutions as the first form.

I found that the $filled_file in webform_document_apply_replacements() isn't initially created with FILE_EXISTS_REPLACE, so a series of filled files with incrementing numbers (as per the FILE_EXISTS_RENAME option on file_unmanaged_copy, see docs) was being created. Since the webform_document_submission_page() function relies on the file name being the same, this means only the first generated docx file was being served.

Attached patch to fix this issue.

areynolds’s picture

Status: Active » Needs review
mikestar5’s picture

Hi,

I have the same problem:

Node tokens are being replaced, but not the submission ones...

My name is [submission:values:name] 

My email is [submission:values:email]

Any idea why?

mikestar5’s picture

Status: Needs review » Active