You are here

function template_preprocess_webform_submission in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.template.inc \template_preprocess_webform_submission()
  2. 6.3 includes/webform.submissions.inc \template_preprocess_webform_submission()
  3. 7.4 includes/webform.submissions.inc \template_preprocess_webform_submission()
  4. 7.3 includes/webform.submissions.inc \template_preprocess_webform_submission()

Prepares variables for webform submission templates.

Default template: webform-submission.html.twig.

Parameters

array $variables: An associative array containing:

  • elements: An array of elements to display in view mode.
  • webform_submission: The webform submissions object.
  • view_mode: View mode; e.g., 'html', 'text', 'table', 'yaml', etc.

File

includes/webform.theme.template.inc, line 261
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_webform_submission(array &$variables) {
  $variables['view_mode'] = $variables['elements']['#view_mode'];
  $variables['navigation'] = $variables['elements']['navigation'];
  $variables['information'] = $variables['elements']['information'];
  $variables['submission'] = $variables['elements']['submission'];
  $variables['webform_submission'] = $variables['elements']['#webform_submission'];
  if ($variables['webform_submission'] instanceof WebformSubmissionInterface) {
    $variables['webform'] = $variables['webform_submission']
      ->getWebform();
  }
}