Module Development

Drupal 7 Field API Fundamentals for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Alternate resources

Sprout Video

Before diving into the code it's important to understand some of the building blocks that make up the Field API. There's a lot of different terminology in the Field API and it helps to understand what each of the terms mean. As well as understanding the relationship between the Fields and Entities in Drupal 7. Knowing these things will give you a strong foundation on which to start exploring the Drupal 7 Field API.

Terms & concepts covered in this video:

  • What is a field? what is an instance?
  • How do fields relate to entities?
  • Field types
  • Field storage
  • Field widgets
  • Field formatters

For more information about these terms see the Drupal.org handbook page: https://drupal.org/node/443540

The Field API in Drupal 7 is actually made up of a bunch of different APIs. In this series we'll be focusing on the Field types API which is used to allow modules to define new field types, widgets, and display formatters. The Field types API is the most commonly used by custom modules.
 
The Field API consists of a set of hooks that you can implement to define your own custom field types with their own unique data collection widgets, storage schema, and behaviors. And sets of functions that can be called to do things like retrieve information about defined fields, pragmatically attach fields to an entity type, and interact in other ways with fields defined by core or other modules.
 
In addition to the Field types API there is also:
 
  • Field CRUD API - creates field instances and bundles, e.g.) what you see on the manage fields page.
  • Field attach API - connects entities and fields, uses info from Field Info API to retrieve defined fields and do things like display their widget on the appropriate entity form when someone tries to edit an entity.
  • Field info API - retrieve information about defined fields and instances.
  • Field storage API - pluggable back-end storage for fields. Defaults to SQL backend provided by core.
  • Field language API - provides native multilingual support for fields.

Legacy Module Development