function SystemMenuOffCanvasForm::buildConfigurationForm

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

Overrides PluginFormInterface::buildConfigurationForm

File

core/modules/system/src/Form/SystemMenuOffCanvasForm.php, line 91

Class

SystemMenuOffCanvasForm
The setting_tray form handler for the SystemMenuBlock.

Namespace

Drupal\system\Form

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = $this->plugin
        ->buildConfigurationForm([], $form_state);
    // Move the menu levels section to the bottom.
    $form['menu_levels']['#weight'] = 100;
    $form['entity_form'] = [
        '#type' => 'details',
        '#title' => $this->t('Edit menu %label', [
            '%label' => $this->menu
                ->label(),
        ]),
        '#open' => TRUE,
        '#access' => !$this->hasMenuOverrides() && $this->menu
            ->access('edit'),
    ];
    $form['entity_form'] += $this->getEntityForm($this->menu)
        ->buildForm([], $form_state);
    // Print the menu link titles as text instead of a link.
    if (!empty($form['entity_form']['links']['links'])) {
        foreach (Element::children($form['entity_form']['links']['links']) as $child) {
            $title = $form['entity_form']['links']['links'][$child]['title'][1]['#title'];
            $form['entity_form']['links']['links'][$child]['title'][1] = [
                '#markup' => $title,
            ];
        }
    }
    // Change the header text.
    $form['entity_form']['links']['links']['#header'][0] = $this->t('Link');
    $form['entity_form']['links']['links']['#header'][1]['data'] = $this->t('On');
    // Remove the label, ID, description, and buttons from the entity form.
    unset($form['entity_form']['label'], $form['entity_form']['id'], $form['entity_form']['description'], $form['entity_form']['actions']);
    // Since the overview form is further nested than expected, update the
    // #parents. See \Drupal\menu_ui\MenuForm::form().
    $form_state->set('menu_overview_form_parents', [
        'settings',
        'entity_form',
        'links',
    ]);
    return $form;
}

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