Skip to main content

How to load the node edit/create form

Posted on May 27, 2020


Given $node, this is how you get the edit form.

$form = \Drupal::entityTypeManager()->getFormObject('node', 'default')->setEntity($node);
$node_form = \Drupal::formBuilder()->getForm($form); // render array

Note: use dependency injection whenever possible.