function menu_link_weight_form_menu_form_alter in Menu Link Weight 8.2
Same name and namespace in other branches
- 8 menu_link_weight.module \menu_link_weight_form_menu_form_alter()
Implements hook_form_FORM_ID_alter() for menu_overview_form().
Adds an anchor tag so we can link to a menu item directly from the node form.
See also
menu_link_weight_node_element_process
File
- ./
menu_link_weight.module, line 41 - Replaces the menu link weight dropdown with a tabledrag widget.
Code
function menu_link_weight_form_menu_form_alter(&$form, FormStateInterface $form_state) {
if (!isset($form['links']['links'])) {
return;
}
foreach (Element::children($form['links']['links']) as $key) {
/** @see \Drupal\menu_ui\MenuForm::buildOverviewTreeForm() */
list(, $plugin_id) = explode(':', $key, 2);
$html_id = 'menu-link-weight-link-id-' . Html::getId($plugin_id);
$form['links']['links'][$key]['#attributes']['id'] = $html_id;
}
}