function field_read_instance

Reads a single instance record from the database.

Generally, you should use field_info_instance() instead, as it provides caching and allows other modules the opportunity to append additional formatters, widgets, and other information.

Parameters

$entity_type: The type of entity to which the field is bound.

$field_name: The field name to read.

$bundle: The bundle to which the field is bound.

array $include_additional: The default behavior of this function is to not return an instance that has been deleted, or whose field is inactive. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.

Return value

An instance structure, or FALSE.

Related topics

14 calls to field_read_instance()
CrudTest::testDeleteField in drupal/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
Test the deletion of a field.
DisplayOverview::submit in drupal/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
Overrides Drupal\field_ui\OverviewBase::submit().
EntityTranslationTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
Sets up a Drupal site for running functional and integration tests.
FieldAttachStorageTest::testFieldAttachDeleteBundle in drupal/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
Test field_attach_delete_bundle().
FieldInstanceCrudTest::testDeleteFieldInstance in drupal/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
Test the deletion of a field instance.

... See full list

File

drupal/core/modules/field/field.crud.inc, line 690
Field CRUD API, handling field and field instance creation and deletion.

Code

function field_read_instance($entity_type, $field_name, $bundle, $include_additional = array()) {
  $instances = field_read_instances(array(
    'entity_type' => $entity_type,
    'field_name' => $field_name,
    'bundle' => $bundle,
  ), $include_additional);
  return $instances ? current($instances) : FALSE;
}