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

47 calls to field_info_instance()
CommentTokenReplaceTestCase::testCommentTokenReplacement in modules/comment/comment.test
Creates a comment, then tests the tokens generated from it.
comment_tokens in modules/comment/comment.tokens.inc
Implements hook_tokens().
DisabledNodeTypeTestCase::testDisabledNodeTypeUpgrade in modules/simpletest/tests/upgrade/upgrade.node.test
Tests a successful upgrade.
FieldAttachStorageTestCase::testFieldAttachCreateRenameBundle in modules/field/tests/field.test
Test field_attach_create_bundle() and field_attach_rename_bundle().
FieldAttachStorageTestCase::testFieldStorageDetailsAlter in modules/field/tests/field.test
Test storage details alteration.

... See full list

File

modules/field/field.info.inc, line 627

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];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.