function template_preprocess_webform_message in Webform 8.5
Same name and namespace in other branches
- 6.x includes/webform.theme.template.inc \template_preprocess_webform_message()
Prepares variables for webform message templates.
Default template: webform-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/
webform.theme.template.inc, line 643 - Preprocessors and helper functions to make theming easier.
Code
function template_preprocess_webform_message(array &$variables) {
$variables['has_parent'] = FALSE;
$element = $variables['element'];
// Ensure #attributes is set.
$element += [
'#attributes' => [],
];
// Special handling for webform 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'];
}
}