To load the login form I am using the following code.
$form = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserLoginForm');
I would like to load the form to create or edit a node. How can I achieve this?
Copying partially from an answer that I gave here: How to alter $form_state before render a form?
To get an add form, you can have to do something like this:
$values = array('type' => $node_type); $node = \Drupal::entityTypeManager() ->getStorage('node') ->create($values); $form = \Drupal::entityTypeManager() ->getFormObject('node', 'default') ->setEntity($node); return \Drupal::formBuilder()->getForm($form);
Edit: Somehow I missed that you said edit. You do exactly the same then, except that you don't create a new $node, you load the one you want to edit and then use that.
As written there, this is based on the entityblock_form module, so if you need this in a block, you can also just use that module.