You are here

menu_position.module in Menu Position 8

Same filename and directory in other branches
  1. 6 menu_position.module
  2. 7.2 menu_position.module
  3. 7 menu_position.module

File

menu_position.module
View source
<?php

/**
 * @file
 * Contains menu_position.module.
 */
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\menu_position\Plugin\Menu\MenuPositionLink;

/**
 * Implements hook_form_FORM_ID_alter() for menu_edit_form().
 */
function menu_position_form_menu_edit_form_alter(&$form, FormStateInterface $form_state) {
  foreach (Element::children($form['links']['links']) as $key) {
    $menu_link = $form['links']['links'][$key];
    if (isset($menu_link['#item']->link) && $menu_link['#item']->link instanceof MenuPositionLink) {
      $form['links']['links'][$key]['enabled']['#disabled'] = TRUE;
      $form['links']['links'][$key]['enabled']['#default_value'] = TRUE;
    }
  }
}

Functions

Namesort descending Description
menu_position_form_menu_edit_form_alter Implements hook_form_FORM_ID_alter() for menu_edit_form().