function MenuLinkContentForm::form

Same name in other branches
  1. 9 core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::form()
  2. 10 core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::form()
  3. 11.x core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::form()

Overrides ContentEntityForm::form

File

core/modules/menu_link_content/src/Form/MenuLinkContentForm.php, line 82

Class

MenuLinkContentForm
Provides a form to add/update content menu links.

Namespace

Drupal\menu_link_content\Form

Code

public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);
    $default = $this->entity
        ->getMenuName() . ':' . $this->entity
        ->getParentId();
    $id = $this->entity
        ->isNew() ? '' : $this->entity
        ->getPluginId();
    $form['menu_parent'] = $this->menuParentSelector
        ->parentSelectElement($default, $id);
    $form['menu_parent']['#weight'] = 10;
    $form['menu_parent']['#title'] = $this->t('Parent link');
    $form['menu_parent']['#description'] = $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.');
    $form['menu_parent']['#attributes']['class'][] = 'menu-title-select';
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.