public function MenuLinkEditForm::buildForm in Drupal 8
Same name and namespace in other branches
- 9 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\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;
}