Topic

Fields

Fields are the building blocks of Drupal's powerful content modeling system. The Field API allows for the development of custom field types, field widgets, and field formatters to suit almost any data display and collection needs. When combined with entities, which allows for the attachment of fields to entity bundles (commonly known as content types), Drupal becomes infinitely flexible without requiring writing any code.

Example tasks

  • Understand how the main components of Drupal's field system fit together
  • Learn how fields can be used to customize your site
  • Customize existing fields and create new additional functionality within your own modules

Confidence

At this point in the development cycle, the Field API is stable. Contributed modules that provide additional field types and add functionality to the field system are likely to emerge, but the main components of the core functionality are unlikely to change.

Drupalize.Me resources

We are still filling out our Drupal 8 library and this page will be updated with new tutorials as they are created.

  • Field API Overview

    • This tutorial, along with those following it in our module development guide, walk through an overview of the Field API. This includes the three main components that make up fields in Drupal (field types, widgets, and formatters).
  • Entities

    • Entities and fields are closely related and it's worth taking the time to understand both.
  • Content Modeling

    • Fields and entities combined give Drupal powerful data modeling tools, and a large amount of flexibility for site builders.
  • What's New in Drupal 8: Entity Field API

    • This video is a high level overview of the entity and field system in Drupal 8, including the main changes for those familiar with Drupal 7.
  • Introduction to Fields in Drupal 7

    • This series, targeted at site builders, covers the main conceptual and structural tasks that a site administrator would use to make the most out of Drupal's field system. Mostly relevant for Drupal 8 too.
  • Drupal 7 Field API: Creating Custom Field Types, Widgets and Formatters

    • This series covers the Field API in Drupal 7 from the module developer's perspective.

More Guides

We have guides on many Drupal skills and topics.

Explore guides

External resources

  • 2.3 Concept: Content Entities and Fields (drupal.org)
    • The role of content types and fields in Drupal.
  • FieldTypes, FieldWidgets, and FieldFormatters (drupal.org)
    • Overview of field types, widgets, and formatters for developers. Includes a handy list of all field types in Drupal core
  • Field API Documentation (api.drupal.org)
  • Field Types API Documentation (api.drupal.org)
    • Together these two links constitute the main API documentation pages for the Field and Field Types APIs. The other pages linked to from here, including the widget and formatter APIs, cover the bulk of the functionality behind Drupal's field system.
  • Creating a custom Field (drupal.org)
    • This tutorial, along with others in progress from drupal.org, walks through the process of creating a custom field.
  • Examples for Developers (drupal.org)
    • The examples projects contains an example module (field_api) with sample code demonstrating adding a new field type, widget, and formatter.