You are here

function template_preprocess_webform_share_iframe in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_share/webform_share.module \template_preprocess_webform_share_iframe()

Prepares variables for webform share iframe templates.

Default template: webform-share-iframe.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #webform, #javascript, #options, and #attributes.

File

modules/webform_share/webform_share.module, line 300
Allows webforms to be shared on other websites using an iframe.

Code

function template_preprocess_webform_share_iframe(array &$variables) {
  $element = $variables['element'];

  // Set javascript.
  $variables['javascript'] = $element['#javascript'];

  // Set iframe-resizer script options.
  $variables['script'] = $element['#script'];
  $options = json_encode($element['#options'], JSON_FORCE_OBJECT);
  $variables['options'] = Markup::create($options);
}