function MenuLinkEditForm::buildForm
Same name in other branches
- 9 core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()
- 8.9.x core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()
- 11.x core/modules/menu_ui/src/Form/MenuLinkEditForm.php \Drupal\menu_ui\Form\MenuLinkEditForm::buildForm()
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
\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 65
Class
- MenuLinkEditForm
- Defines a generic edit form for all menu link plugin types.
Namespace
Drupal\menu_ui\FormCode
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.