You are here

public function MenuLinkContentForm::form in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::form()

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

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;
}