I have a custom field and custom field formatter created in Drupal 8. I need to remove the default FIELD VALUE wrappers so that I can build an HTML table with the field values.

The field formatter is currently using a custom twig template, but I <div>'s are being rendered prior to the template, so I can't remove them there.

How can this be accomplished?

1 Answer 1


The div wrapper you are looking for is probably in field.html.twig. Drupal provides a theme name suggestion for a custom field type automatically, so you can override this template by placing field--myfieldtype.html.twig in the theme templates folder.

If you want you can deliver a default template with the custom field module, like the comment module does for the comment field:


Then you need to define a theme hook in mymodule.module.

Example from the comment module:

 * Implements hook_theme().
function comment_theme() {
  return [
    // ...
    'field__comment' => [
      'base hook' => 'field',

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.