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.
Problem/Motivation
The patch introduced in issue 3166397 made it impossible to manipulate webform submission data in hook_preprocess_entity_print. The code added to the file webform_entity_print.module (lines 297 -> 299) overwrites the content variable with a Markup element so you can't retrieve submission data from $variables['content'][0]['#webform_submission'] with the hook anymore.
// The HTML markup is safe because it has already been rendered.
$content = [
'#markup' => Markup::create($html),
];
Steps to reproduce
Create a custom module hook_preprocess_entity_print and dump $variables with kint
Proposed resolution
Comment | File | Size | Author |
---|---|---|---|
#11 | webform-entity-print.patch | 567 bytes | vivek.kekare |
#2 | 3188792-2.patch | 573 bytes | jrockowitz |
Kint variables in hook preprocess entity print.png | 129.87 KB | bartvermeulen1 |
Issue fork webform-3188792
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI don't want to revert #3166397: include element image(thumbnail) in pdf document because everyone expects the images to render via PDF documents.
Does add $variables['webform_submission'] solve the problem?
Comment #3
bartvermeulen1 CreditAttribution: bartvermeulen1 commentedAdding $variables['webform_submission'] solves the problem. Thanks!
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think we should backport this to 8.x-5.x.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #11
vivek.kekare CreditAttribution: vivek.kekare commented#2 doesn't work for me, I saw same code already exist at the start of webform_entity_print_preprocess_entity_print method. So I created new patch to get it worked.
Comment #12
Kris77 CreditAttribution: Kris77 commentedPatch #11 works for me...thanks @vivek.kekare
Comment #13
Kris77 CreditAttribution: Kris77 commentedThis problem is present in Webform 6.1.4 and patch in #11 works again.
Thanks @vivek.kekare
Comment #14
Kris77 CreditAttribution: Kris77 commentedI don't know if it's only my problem, but it seems that Preprocess entity print works only in theme folder.
I have created a custom module:
It does not work.
If move mycustom module folder in my theme or sub theme then it works.
Comment #15
antonio.bertolini CreditAttribution: antonio.bertolini commentedThis problem is present in Webform 6.2.2 and patch in #11 works at line 366.
It' only 1 row.... why not apply it definitively?... I use entity print submission in 10+ sites it's a waste of time everytimes!
thanks!
A.