How do I render/display an existing content type form in a custom twig template for a custom module in drupal 8?

I've tried using getform() function, but I dont think that is the correct function.

I have set a preprocessor variable in my custom module and can see the variable on my custom page via the twig syntax {{dump()}}. Just for simplicity, I would like to know, which class function will allow me to simply render the content type 'article' form , once I can see the article form, i can change it to my custom made form.

1 Answer 1


I'm not sure what you're exactly asking, but there are various modules that allow you to display entity forms in a block, for example Entityform block (Disclaimer, maintained by me).

Either use that, you can use form modes and/or form alters to then customize the form, or just look at the code to see how to do it.

One thing that this module doesn't support yet is editing existing entities, I'd love to add support for that using the plugin context system.

  • Thanks Berdir, you have got me on the right track now. Only started using Drupal about a month ago. But willing to learn about making my own modules in the hope of better understanding Drupal.
    – Jamie
    Mar 13, 2016 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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