function MenuLinkEditForm::buildForm

Same name and namespace in other branches
  1. 9 core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()
  2. 10 core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()
  3. 11.x core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()

Parameters

\Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin: The plugin instance to use for this form.

Overrides FormInterface::buildForm

File

core/modules/menu_ui/src/Form/MenuLinkEditForm.php, line 61

Class

MenuLinkEditForm
Defines a generic edit form for all menu link plugin types.

Namespace

Drupal\menu_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, MenuLinkInterface $menu_link_plugin = NULL) {
    $form['menu_link_id'] = [
        '#type' => 'value',
        '#value' => $menu_link_plugin->getPluginId(),
    ];
    $class_name = $menu_link_plugin->getFormClass();
    $form['#plugin_form'] = $this->classResolver
        ->getInstanceFromDefinition($class_name);
    $form['#plugin_form']->setMenuLinkInstance($menu_link_plugin);
    $form += $form['#plugin_form']->buildConfigurationForm($form, $form_state);
    $form['actions'] = [
        '#type' => 'actions',
    ];
    $form['actions']['submit'] = [
        '#type' => 'submit',
        '#value' => $this->t('Save'),
        '#button_type' => 'primary',
    ];
    return $form;
}

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