0

I'm able to load node create forms like so

$node    = \Drupal\node\Entity\Node::create(['type' => 'avenue']);
$content = \Drupal::service('entity.form_builder')->getForm($node);

return $content;

However what if I want to load an edit form for a pre-existing node? I looked on this page https://api.drupal.org/api/drupal/core!modules!node!src!Entity!Node.php/class/Node/8.2.x but I can't find anything that would relate to the edit form. Is there a way to load the edit form for a specific node?

  • 1
    Isn't it the same? As in, pass an existing $node object to getForm? – Clive Dec 29 '16 at 20:18
2

Yes, on the linked page you would find Node::load() to get a pre-existing node:

$node    = \Drupal\node\Entity\Node::load($nid);
$content = \Drupal::service('entity.form_builder')->getForm($node);

return $content;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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