Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Entities, Bundles, Fields and Field instances

Parent Feed: 

Drupal 7 introduces a number of new apis and with those comes new jargon. Untangling that could be daunting. I'll try to briefly sketch what is what and relate it to terminology outside of the Drupal world.

This post is a work in progress, I am regularly revising the text from feedback.

Note Revised paragraph order and wording, clarified wording of definitions, added references, corrected glitches

Entities

An entity is an abstract data type in drupal. An Entity type is required to implement the Entity interfaces as defined in the core Entity API. It is a generalisation of the node, comment, user, taxonomy term types of previous versions of Drupal. In Drupal 7, only the R from CRUD is specified in core, but work is underway to fill the gap in next versions. There is a contributed Entity API module, which aims to do it. Entities can have multiple bundles

Bundles

Bundles are groups of fields. A bundle is a specialisation, an instance of an entity. If node is an entity, then an article is an bundle. This allows distinguishing the kinds and types within the system - kinds classify types, types classify values (concrete objects)

Fields

Fields are the incarnation of the CCK data type of the same name moved to Drupal core. What are they? The answer can be found by reading Field Api. In essence, a field is a primitive drupal data type implementing the interface described in those pages. Fields have an associated schema, formatter(s), widget(s) and settings. Example field types - file field, text field, etc... Modules can define new field types.

Field Instances

A Field Instance is a concrete specialisation of a field type. It captures the field type together with its configuration - schema, formatter and widget. Field instances are attached to bundles.

Fieldable objects

The term is sometimes used for entities and bundles.

This concludes the quick jargon tour. And last something to ponder - can a field be an entity?

References

  1. Field API
  2. Field API datastructures
  3. Entity API contributed module. Provides Entity CRUD and metadata
  4. Drupal 7 Entities And Fields-Transitioning To D7 presentation slides from Copenhagen
  5. Drupal 7 Entities And Fields-Transitioning To D7 video of the presentation
  6. How Drupal 7 fields are changing the way you write modules
Author: 
RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web