6

I am working on porting a D7 module to D8. As in Drupal 8 all things are represented as entity, menu items are also represented as entity. Now I added a hook_form_BASE_FORM_ID_alter() implementation to alter the menu creation and edit form. On the menu edit form, I want to get the entity ID of the menu that is currently being edited.

I tried to get the entity id ID with the following code, but I am getting an error. (See line 43.)

$entity = $form_state['controller']->getEntity();

For above snippet I followed https://www.drupal.org/node/1734556.

How can I get the entity ID?

1 Answer 1

12

That CR is outdated, probably there's a later CR updating it: now you should use $form_state->getFormObject()->getEntity().

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.