function MenuLinkDefaultForm::buildConfigurationForm
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::buildConfigurationForm()
- 10 core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::buildConfigurationForm()
- 11.x core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php \Drupal\Core\Menu\Form\MenuLinkDefaultForm::buildConfigurationForm()
Overrides PluginFormInterface::buildConfigurationForm
1 call to MenuLinkDefaultForm::buildConfigurationForm()
- ViewsMenuLinkForm::buildConfigurationForm in core/
modules/ views/ src/ Plugin/ Menu/ Form/ ViewsMenuLinkForm.php - Form constructor.
1 method overrides MenuLinkDefaultForm::buildConfigurationForm()
- ViewsMenuLinkForm::buildConfigurationForm in core/
modules/ views/ src/ Plugin/ Menu/ Form/ ViewsMenuLinkForm.php - Form constructor.
File
-
core/
lib/ Drupal/ Core/ Menu/ Form/ MenuLinkDefaultForm.php, line 93
Class
- MenuLinkDefaultForm
- Provides an edit form for static menu links.
Namespace
Drupal\Core\Menu\FormCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['#title'] = $this->t('Edit menu link %title', [
'%title' => $this->menuLink
->getTitle(),
]);
$provider = $this->menuLink
->getProvider();
$form['info'] = [
'#type' => 'item',
'#title' => $this->t('This link is provided by the @name module. The title and path cannot be edited.', [
'@name' => $this->moduleHandler
->getName($provider),
]),
];
$form['id'] = [
'#type' => 'value',
'#value' => $this->menuLink
->getPluginId(),
];
$link = [
'#type' => 'link',
'#title' => $this->menuLink
->getTitle(),
'#url' => $this->menuLink
->getUrlObject(),
];
$form['path'] = [
'link' => $link,
'#type' => 'item',
'#title' => $this->t('Link'),
];
$form['enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable menu link'),
'#description' => $this->t('Menu links that are not enabled will not be listed in any menu.'),
'#default_value' => $this->menuLink
->isEnabled(),
];
$form['expanded'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show as expanded'),
'#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded. This option may be overridden for the entire menu tree when placing a menu block.'),
'#default_value' => $this->menuLink
->isExpanded(),
];
$menu_parent = $this->menuLink
->getMenuName() . ':' . $this->menuLink
->getParent();
$form['menu_parent'] = $this->menuParentSelector
->parentSelectElement($menu_parent, $this->menuLink
->getPluginId());
$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';
$delta = max(abs($this->menuLink
->getWeight()), 50);
$form['weight'] = [
'#type' => 'number',
'#min' => -$delta,
'#max' => $delta,
'#default_value' => $this->menuLink
->getWeight(),
'#title' => $this->t('Weight'),
'#description' => $this->t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.