You are here

function D7field_tools_info_instances in Field tools 8

Helper to get a list of all instances of a field.

Parameters

$field_name: The name of a field.

Return value

An array of entity types and bundles this field has instances on. Keys are entity types, values are arrays of bundle names.

File

./field_tools.module, line 291
field_tools.module Contains useful tools for working with fields.

Code

function D7field_tools_info_instances($field_name) {
  $instances = field_info_instances();
  $field_bundles = array();
  foreach ($instances as $entity_type => $bundles) {
    foreach ($bundles as $bundle => $bundle_instances) {
      if (isset($bundle_instances[$field_name])) {
        $field_bundles[$entity_type][] = $bundle;
      }
    }
  }
  return $field_bundles;
}