function webform_preprocess_menu_local_action in Webform 8.5
Same name and namespace in other branches
- 6.x includes/webform.theme.inc \webform_preprocess_menu_local_action()
Implements preprocess_menu_local_action() for single local action link templates.
Applies custom link attributes to local actions. Custom attributes are used to open Webform UI modals.
See also
template_preprocess_menu_local_action();
\Drupal\webform\WebformEntityHandlersForm
\Drupal\webform_ui\WebformUiEntityEditForm
https://www.drupal.org/node/2897396
File
- includes/
webform.theme.inc, line 246 - Theme hooks, preprocessor, and suggestions.
Code
function webform_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
// Only need to update local actions with link attributes.
if (!isset($link['attributes'])) {
return;
}
$link += [
'localized_options' => [],
];
$link['localized_options']['attributes'] = $link['attributes'];
$link['localized_options']['attributes']['class'][] = 'button';
$link['localized_options']['attributes']['class'][] = 'button-action';
$link['localized_options']['set_active_class'] = TRUE;
$variables['link'] = [
'#type' => 'link',
'#title' => $link['title'],
'#options' => $link['localized_options'],
'#url' => $link['url'],
];
}