You are here

function template_preprocess_webform_element_more in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.template.inc \template_preprocess_webform_element_more()

Prepares variables for webform element more templates.

Default template: webform-element-more.html.twig.

Parameters

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

  • element: The webform element.

File

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

Code

function template_preprocess_webform_element_more(array &$variables) {
  if (empty($variables['more_title'])) {
    $variables['more_title'] = \Drupal::config('webform.settings')
      ->get('element.default_more_title');
  }
  if (!is_array($variables['more'])) {
    $variables['more'] = [
      '#markup' => $variables['more'],
      '#allowed_tags' => WebformHtmlEditor::getAllowedTags(),
    ];
  }
  $variables['attributes'] = new Attribute($variables['attributes']);

  // Make sure there is a unique id.
  if (empty($variables['id'])) {
    $variables['id'] = Html::getUniqueId('webform-element-more');
  }

  // Make sure attributes id is set.
  if (!isset($variables['attributes']['id'])) {
    $variables['attributes']['id'] = $variables['id'];
  }
}