I have been unable to theme a webform that is displayed through the webform reference field.

Following the template suggestions, the format would be webform--name-of-form.html.twig. This is not the case though.

I did some research and it seem that the template suggestions don't fire off when rendering a form through the reference field, and thus you are unable to target it to create a theme file.

Comments

devkinetic created an issue. See original summary.

devkinetic’s picture

Title: Webform referance field theming » Webform reference field theming
Issue summary: View changes
devkinetic’s picture

Issue summary: View changes
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new1.46 KB

Looks like the webform.html.twig template had no template suggestions available.

Let's see if the attached patch passes all the tests and then I will just commit it.

devkinetic’s picture

Will this work? I'm going to test but based on my research it looked like the fact that $variables['webform'] wasn't being passed was the culprit.

elseif (isset($variables['webform'])) {
    /** @var \Drupal\webform\WebformInterface $webform */
    $webform = $variables['webform'];
    $suggestions[] = $hook . '__' . $webform->id();
  }

Same thing with possibly with $variables['webform_submission']

  • jrockowitz committed acfdeb5 on 8.x-5.x
    Issue #2847441 by jrockowitz, devkinetic: Webform reference field...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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