Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#7 | 2562743-replace-not-rename.patch | 700 bytes | areynolds |
#5 | Application (1) (1).zip | 10.75 KB | Kwaailappies |
#3 | webform_document_test.zip | 3.35 KB | earthangelconsulting |
Comments
Comment #2
rafenden CreditAttribution: rafenden at Digital Crafts Agency Ltd. commentedHi goatvirus,
please upload and example docx file.
Comment #3
earthangelconsulting CreditAttribution: earthangelconsulting commentedhere's my docx file (in zip format, this website wouldn't allow a file of type docx)
Comment #4
earthangelconsulting CreditAttribution: earthangelconsulting commentedhello @rafal.enden does that uploaded file throw any light on why this isn't working for me?
Comment #5
Kwaailappies CreditAttribution: Kwaailappies commentedHi,
My Document is a docx but also doesn't replace tokens with values I have tried all sorts of token format, please help me.
Comment #6
rafenden CreditAttribution: rafenden at Digital Crafts Agency Ltd. commentedgoatvirus, 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]
Comment #7
areynolds CreditAttribution: areynolds as a volunteer commentedOne 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.
Comment #8
areynolds CreditAttribution: areynolds as a volunteer commentedComment #9
mikestar5 CreditAttribution: mikestar5 commentedHi,
I have the same problem:
Node tokens are being replaced, but not the submission ones...
Any idea why?
Comment #10
mikestar5 CreditAttribution: mikestar5 commented