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

Issue fork webform-3188792

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bartvermeulen1 created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
FileSize
573 bytes

I 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?

bartvermeulen1’s picture

Adding $variables['webform_submission'] solves the problem. Thanks!

jrockowitz’s picture

Version: 6.0.0-beta2 » 8.x-5.x-dev

I think we should backport this to 8.x-5.x.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz authored 97a4ef3 on 8.x-5.x
    Issue #3188792 by jrockowitz, bartvermeulen1: Preprocess entity print
    

  • jrockowitz authored 97a4ef3 on 6.x
    Issue #3188792 by jrockowitz, bartvermeulen1: Preprocess entity print
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

vivek.kekare made their first commit to this issue’s fork.

vivek.kekare’s picture

FileSize
567 bytes

#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.

Kris77’s picture

Patch #11 works for me...thanks @vivek.kekare

Kris77’s picture

This problem is present in Webform 6.1.4 and patch in #11 works again.

Thanks @vivek.kekare

Kris77’s picture

I 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:

  • In mycustom.module file there is mycustom_preprocess_entity_print function
  • In templates folder there is entity-print--webform-submission--test.html.twig for customize pdf
  • Clear cache

It does not work.
If move mycustom module folder in my theme or sub theme then it works.

antonio.bertolini’s picture

This 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.