Hi Jacob.

It looks like Entity Print module stopped recognizing the webform-submission.html.twig template. I had this template configured with custom markup, which was working with previous versions of the Webform module.

After some digging, I saw this old webform issue that may be related? https://www.drupal.org/project/webform/issues/2883402

```The entityprint.module module is looking a 'full' view mode, which was not supported by webform submissions.
The attached patch defaults any missing view mode to 'html' and outputs the submissions data with the submission information.```

I tested a node template with Entity Print and it worked with the custom markup.

Any insight?

Thank you.
Jim

Webform 8.x-5.1
Entity Print 8.x-2.1
Drupal core 8.6.10

Comments

jim22 created an issue. See original summary.

jim22’s picture

Issue summary: View changes
jrockowitz’s picture

Here the entity print URL format.

/print/pdf/webform_submission/SID
/print/pdf/webform_submission/SID/debug (Shows the HTML converted to PDF)

jrockowitz’s picture

StatusFileSize
new181.83 KB

Using /print/pdf/webform_submission/SID/debug with Twig debugging enabled the template suggestions are now

<!-- THEME HOOK: 'entity_print__webform_submission__contact' -->
<!-- FILE NAME SUGGESTIONS:
   * entity-print--webform-submission--contact.html.twig
   * entity-print--webform-submission.html.twig
   x entity-print.html.twig
-->
<!-- BEGIN OUTPUT from 'modules/contrib/entity_print/templates/entity-print.html.twig' -->

jrockowitz’s picture

Here is the source of this change and when webform submission template is missing.

#3017333: Hide submission information from the edit submission page, css only working for admin not anonymous users

We might need to fix this for just the entity print module (aka full display mode)

I think we can use hook_entity_view_alter() to fix this regression.

jrockowitz’s picture

The below hooks fixes the problem.

/**
 * Implements hook_ENTITY_TYPE_view_alter().
 */
function CUSTOM_MODULE_webform_submission_view_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
  if ($build['#view_mode'] === 'full') {
    $build['#theme'] = 'webform_submission';
    $build['submission'] = $build['data'];
  }
}

Still, I think there might be a better approach.

jim22’s picture

Thanks, Jacob. Much appreciated!

jrockowitz’s picture

The below webform-submission.html.twig template contains the information, navigation, and the submission (aka data). The bigger issue is the submission (aka data) no longer has a template around it. The template should be provided by the WebformSubmissionViewBuilder and should be called webform-submission-data.html.twig. I think we can make this improvement without causing any regressions.

The webform-submission-data.html.twig would be used by the entity_print.module and provide a consistent way to alter the submission data without the information or navigation.

{#
/**
 * @file
 * Default theme implementation for webform submission.
 *
 * Available variables:
 * - elements: An array of elements to display in view mode.
 * - webform_submission: The webform submission.
 * - webform: The webform.
 *
 * @see template_preprocess_webform_submission()
 *
 * @ingroup themeable
 */
#}
{%
set classes = [
'webform-submission',
'webform-submission--webform-' ~ webform.id()|clean_class,
webform_submission.isSticky() ? 'webform-submission--sticky',
view_mode ? 'webform-submission--view-mode-' ~ view_mode|clean_class,
]
%}
<div{{ attributes.addClass(classes) }}>
{{ navigation }}
{{ information }}
{{ submission }}
</div>
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new5.18 KB

Status: Needs review » Needs work

The last submitted patch, 9: 3041602-9.patch, failed testing. View results

  • jrockowitz committed ac5823c on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...
  • jrockowitz committed c44c38c on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...

  • jrockowitz committed ac5823c on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...
  • jrockowitz committed c44c38c on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...

  • jrockowitz committed 57f8a3e on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...

  • jrockowitz committed 9d440f4 on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...

  • jrockowitz committed 091294f on 3041602-submission-data
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new14.1 KB
jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz committed ab639a4 on 8.x-5.x
    Issue #3041602 by jrockowitz: Entity Print webform_submission template...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

maloojackson’s picture

Hello, please if i want to render fields data with {{ submission }}, it is {{ submission.first_name }}? Please help. Thanks

jrockowitz’s picture

The Webform module's issue queue is for bugs, feature requests, and planning. Please post general support questions to Drupal Answers. You can also ask questions or help answer questions on the #webform channel on Drupal Slack.