I have a content type Project and it has a more than 100 fields in the node form. The form fields are grouped in different section and category. I tried to use a field_group module to group and categories in different sections, but when I add more than 20 groups field I got a problem in field arrangement and save the changes in form display. Also, i am facing difficulty to theme the form as per the design.

So, is it possible to define template suggestions for node add and edit form by content type and add an individual form element in the form template, where I can define my own HTML structure?

Eg: from--project.html.twig some things like this, and able to add individual form elements in the form template.

<form{{ attributes }}>
 {{ form.title }}
 {{ form.field_project_description }}

Thanks for any help.


1 Answer 1


I usually use something like this for template form suggestions : (works for all forms, not only entity forms)

 * Implements hook_theme_suggestions_HOOK_alter().
function <HOOK>_theme_suggestions_form_alter(array &$suggestions, array $variables) {
  if (isset($variables['element']['#theme']) && is_array($variables['element']['#theme'])) {
    foreach ($variables['element']['#theme'] as $theme) {
      if (strpos($theme, '_edit_') !== FALSE) {
        $suggestions[] = 'form__' . str_replace('_edit_', '_', $theme);
      $suggestions[] = 'form__' . $theme;
  • Since the OP asked for individual form elements in a node edit form I wouldn't recommend the form wrapper template, a better choice would be node-edit-form--content-type.html.twig, see drupal.stackexchange.com/questions/231192/…
    – 4uk4
    Commented Nov 16, 2018 at 12:35

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.