function field_info_instance

Returns an array of instance data for a specific field and bundle.

The function populates a static cache with all fields and instances used in the bundle, allowing fast retrieval of field_info_field() or field_info_instance() later in the request.

Parameters

$entity_type: The entity type for the instance.

$field_name: The field name for the instance.

$bundle_name: The bundle name for the instance.

Return value

An associative array of instance data for the specific field and bundle; NULL if the instance does not exist.

Related topics

51 calls to field_info_instance()
BulkDeleteTest::testDeleteFieldInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that deleting an instance leaves the field data items in the database and that the appropriate Field API functions can operate on the deleted data and instance.
BulkDeleteTest::testPurgeField in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that fields are preserved and purged correctly as multiple instances are deleted and purged.
BulkDeleteTest::testPurgeInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that field data items and instances are purged when an instance is deleted.
CommentTokenReplaceTest::testCommentTokenReplacement in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
Creates a comment, then tests the tokens generated from it.
comment_tokens in drupal/core/modules/comment/comment.tokens.inc
Implements hook_tokens().

... See full list

File

drupal/core/modules/field/field.info.inc, line 456
Field Info API, providing information about available fields and field types.

Code

function field_info_instance($entity_type, $field_name, $bundle_name) {
  $cache = _field_info_field_cache();
  $info = $cache
    ->getBundleInstances($entity_type, $bundle_name);
  if (isset($info[$field_name])) {
    return $info[$field_name];
  }
}