function menu_trail_by_path_form_menu_form_alter in Menu Trail By Path 8
Implements hook_form_FORM_ID_alter().
File
- ./
menu_trail_by_path.module, line 38 - Expand menu items and set active-trail according to current path.
Code
function menu_trail_by_path_form_menu_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/** @var \Drupal\system\MenuInterface $menu */
$menu = $form_state
->getFormObject()
->getEntity();
// Add menu trail third party settings.
$form['third_party_settings']['#tree'] = TRUE;
$form['third_party_settings']['menu_trail_by_path']['trail_source'] = [
'#type' => 'select',
'#title' => t('Menu Trail Source'),
'#description' => t('Default behavior can be updated on the <a href=":url">settings</a> page.', [
':url' => Url::fromRoute('menu_trail_by_path.settings')
->toString(),
]),
'#empty_option' => t('Use default behavior'),
'#options' => MenuTrailByPathSettingsForm::getTrailSourceOptions(),
'#default_value' => $menu
->getThirdPartySetting('menu_trail_by_path', 'trail_source'),
];
}