You are here

function _shs_get_instances in Simple hierarchical select 7

Helper function to get all instances of widgets with type "taxonomy_shs".

Parameters

string $entity_type: Name of entity type.

string $bundle: Name of bundle (optional).

Return value

array List of instances keyed by field name.

File

./shs.module, line 1134
Provides an additional widget for term fields to create hierarchical selects.

Code

function _shs_get_instances($entity_type, $bundle = NULL) {
  $instances = array();
  $field_instances = field_info_instances($entity_type, $bundle);

  // Get all field instances with widget type "shs_taxonomy".
  if (empty($bundle)) {
    foreach ($field_instances as $bundle_name => $bundle_instances) {
      foreach ($bundle_instances as $instance) {
        if ($instance['widget']['type'] == 'taxonomy_shs') {
          $instances[$bundle_name][$instance['field_name']] = $instance;
        }
      }
    }
  }
  else {
    foreach ($field_instances as $instance) {
      if ($instance['widget']['type'] == 'taxonomy_shs') {
        $instances[$instance['field_name']] = $instance;
      }
    }
  }
  return $instances;
}