You are here

function template_preprocess_yamlform_submission_table in YAML Form 8

Prepares variables for form submission table template.

Default template: yamlform-submission-table.html.twig.

Parameters

array $variables: An associative array containing the following key:

  • yamlform_submission: A form submission.

File

includes/yamlform.theme.inc, line 322
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_yamlform_submission_table(array &$variables) {

  /** @var \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission */
  $yamlform_submission = $variables['yamlform_submission'];

  /** @var \Drupal\yamlform\YamlFormSubmissionViewBuilderInterface $view_builder */
  $view_builder = \Drupal::entityTypeManager()
    ->getViewBuilder('yamlform_submission');
  $yamlform = $yamlform_submission
    ->getYamlForm();
  $data = $yamlform_submission
    ->getData();
  $elements = $yamlform
    ->getElementsFlattenedAndHasValue();
  $variables['table'] = $view_builder
    ->buildTable($elements, $data);
}