Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Introduction to the Drupal 7 Field API Series

Video loading...

  • 0:00
    [MUSIC PLAYING]
  • 0:05
    DRUPAL 7 FIELD API-- Everything You Need to Know About The Drupal
  • 0:08
    7 Field API with Joe Shindelar
  • 0:17
    Fields are the building blocks
  • 0:19
    of Drupal's powerful content modeling system.
  • 0:21
    And the field API allows for the development of custom field types
  • 0:25
    to suit almost any data display and collection needs.
  • 0:29
    Drupal has a long history of providing ways for developers
  • 0:32
    to create custom field types that can be bundled together
  • 0:35
    and attached to various pieces of content.
  • 0:37
    The place that you've likely encountered this first
  • 0:39
    is creating custom node types or adding
  • 0:42
    new fields to an existing node type.
  • 0:45
    Then, you'll likely start seeing it everywhere
  • 0:48
    as you look around in Drupal.
  • 0:49
    Fields allow a Drupal Site Administrator
  • 0:52
    to create an information architecture that matches the needs
  • 0:54
    of each individual site instead of having to try to rely
  • 0:57
    on one solution that fits every scenario.
  • 1:01
    Drupal Core comes with a handful of really common field types
  • 1:04
    for storing things like strings of text, numbers, and even images,
  • 1:08
    allowing you to mix and match these different fields to define
  • 1:11
    the content the makes sense for your site.
  • 1:13
    Fields are one of the things that really differentiates
  • 1:16
    Drupal from much of its competition.
  • 1:19
    As a model developer, the field API provides a way for us
  • 1:22
    to define new types of data and methods
  • 1:25
    for collecting and displaying that data as a new field type, which is
  • 1:29
    great, because it means I can write a module that defines a video field
  • 1:32
    and how to store, collect, and display the related information.
  • 1:36
    But since it's just a regular field, administrators can mix and match it
  • 1:40
    with other fields however they see fit.
  • 1:43
    This makes my module and its functionality
  • 1:45
    infinitely more useful, since I'm only defining how my specific data
  • 1:49
    works and not the context in which it's used.
  • 1:52
    This series will provide you with all the information you need to be
  • 1:56
    able to define a custom field in your own module.
  • 1:59
    There are a lot of components to the field API,
  • 2:01
    and we're not going to cover all of them,
  • 2:03
    but we will go through everything you need in order
  • 2:05
    to define a custom field type and tell Drupal what values your field
  • 2:09
    can store, how to collect those values, and how to display them.
  • 2:14
    We'll start out by defining various field API terms like formatter
  • 2:17
    and widget and locate the documentation
  • 2:20
    and resources for the field API.
  • 2:22
    Then, we'll walk through defining the type of data
  • 2:25
    that our field is going to store by implementing the appropriate field
  • 2:29
    type hooks and looking at how that affects our site's database.
  • 2:33
    After that, we'll create a user interface with administrator
  • 2:37
    configurable settings for allowing someone
  • 2:39
    to enter a value for our custom field.
  • 2:42
    Followed by examining the ways in which we can output the field data
  • 2:45
    we've collected and display it for end users.
  • 2:49
    After completing all the lessons in this series,
  • 2:52
    you should have a firm grasp of the Drupal 7 field API and the tools
  • 2:56
    and knowledge you need in order to define your own custom field types.

Introduction to the Drupal 7 Field API Series

Loading...

Fields are the building blocks of Drupal's powerful content modeling system. The field API allows for the development of custom field types to suit almost any data display and collection needs. Developers can create custom field types that can be bundled together and attached to various pieces of content. Fields allow a Drupal Site Administrator to create an information architecture that matches the needs of each individual site.

This series will provide you with all the information you need to be able to define a custom field in your own module. After completing all the lessons in this series, you should have a firm grasp of the Drupal 7 field API and the tools and knowledge you need in order to define your own custom field types.

Prerequisites

This series requires an understanding of PHP and basic Drupal 7 module development. For a refresher, or if you get stuck, check out our Drupal 7 Module Development series.

Additional resources: