I have always separated my field names by entity. e.g.

field_paragraph_h2 or field_content_h2,

but when you look at config, fields are designated by their entity type as well.

field.field.paragraph.paragraph_type.field_paragraph_h2 or field.field.node.content_type.field_content_h2

Am I safe using just field_h2 for both entity type field names, or are there instances with Drupal where this may be problematic?


field.field.paragraph.paragraph_type.field_h2 or field.field.node.content_type.field_h2


You are safe to use the same name. The fields are unique for each entity type, even when they have the same name.

They have their own field storage configuration, instances and will be stored to dedicated database tables per entity type.

  • *edit: One reason that got me wondering is that in field.html.twig, for example, {{ field_name }} returns only the field machine name. This is fine because it is the theming layer, my concerns were for preprocessing where php errors/collisions could occur. – Prestosaurus Mar 22 at 16:09

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.