function MenuLinkContentForm::buildEntity
Same name in other branches
- 9 core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::buildEntity()
- 10 core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::buildEntity()
- 11.x core/modules/menu_link_content/src/Form/MenuLinkContentForm.php \Drupal\menu_link_content\Form\MenuLinkContentForm::buildEntity()
Overrides ContentEntityForm::buildEntity
File
-
core/
modules/ menu_link_content/ src/ Form/ MenuLinkContentForm.php, line 110
Class
- MenuLinkContentForm
- Provides a form to add/update content menu links.
Namespace
Drupal\menu_link_content\FormCode
public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $entity */
$entity = parent::buildEntity($form, $form_state);
list($menu_name, $parent) = explode(':', $form_state->getValue('menu_parent'), 2);
$entity->parent->value = $parent;
$entity->menu_name->value = $menu_name;
$entity->enabled->value = !$form_state->isValueEmpty([
'enabled',
'value',
]);
$entity->expanded->value = !$form_state->isValueEmpty([
'expanded',
'value',
]);
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.