Field API

  1. 7.x drupal/modules/field/field.module field
  2. 8.x drupal/core/modules/field/field.module field

Attaches custom data fields to Drupal entities.

The Field API allows custom data fields to be attached to Drupal entities and takes care of storing, loading, editing, and rendering field data. Any entity type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it. Other modules can provide a user interface for managing custom fields via a web browser as well as a wide and flexible variety of data type, form element, and display format capabilities.

The Field API defines two primary data structures, Field and Instance, and the concept of a Bundle. A Field defines a particular type of data that can be attached to entities. A Field Instance is a Field attached to a single Bundle. A Bundle is a set of fields that are treated as a group by the Field Attach API and is related to a single fieldable entity type.

For example, suppose a site administrator wants Article nodes to have a subtitle and photo. Using the Field API or Field UI module, the administrator creates a field named 'subtitle' of type 'text' and a field named 'photo' of type 'image'. The administrator (again, via a UI) creates two Field Instances, one attaching the field 'subtitle' to the 'node' bundle 'article' and one attaching the field 'photo' to the 'node' bundle 'article'. When the node storage loads an Article node, it loads the values of the 'subtitle' and 'photo' fields because they are both attached to the 'node' bundle 'article'.

  • Field Types API: Defines field types, widget types, and display formatters. Field modules use this API to provide field types like Text and Node Reference along with the associated form elements and display formatters.

Functions

Namesort descending Location Description
field_cron drupal/core/modules/field/field.module Implements hook_cron().
field_entity_bundle_delete drupal/core/modules/field/field.module Implements hook_entity_bundle_delete().
field_entity_bundle_field_info drupal/core/modules/field/field.module Implements hook_entity_bundle_field_info().
field_entity_bundle_rename drupal/core/modules/field/field.module Implements hook_entity_bundle_rename().
field_entity_field_storage_info drupal/core/modules/field/field.module Implements hook_entity_field_storage_info().
field_filter_xss drupal/core/modules/field/field.module Filters an HTML string to prevent cross-site-scripting (XSS) vulnerabilities.
field_help drupal/core/modules/field/field.module Implements hook_help().
field_system_info_alter drupal/core/modules/field/field.module Implements hook_system_info_alter().
_field_filter_xss_allowed_tags drupal/core/modules/field/field.module Returns a list of tags allowed by field_filter_xss().
_field_filter_xss_display_allowed_tags drupal/core/modules/field/field.module Returns a human-readable list of allowed tags for display in help texts.

File

drupal/core/modules/field/field.module, line 22
Attach custom data fields to Drupal entities.