You are here

function template_preprocess_yamlform_message in YAML Form 8

Prepares variables for Form message templates.

Default template: yamlform-message.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #id, #attributes, #children.

See also

template_preprocess_container()

File

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

Code

function template_preprocess_yamlform_message(&$variables) {
  $variables['has_parent'] = FALSE;
  $element = $variables['element'];

  // Ensure #attributes is set.
  $element += [
    '#attributes' => [],
  ];

  // Special handling for form elements.
  if (isset($element['#array_parents'])) {

    // Assign an html ID.
    if (!isset($element['#attributes']['id'])) {
      $element['#attributes']['id'] = $element['#id'];
    }
    $variables['has_parent'] = TRUE;
  }
  $variables['message'] = $element['#message'];
  $variables['attributes'] = $element['#attributes'];
  if (isset($element['#closed'])) {
    $variables['closed'] = $element['#closed'];
  }
}