You are here

function field_tools_options_entity_bundle in Field tools 8

Same name and namespace in other branches
  1. 7 field_tools.admin.inc \field_tools_options_entity_bundle()

Helper to get FormAPI options for entity bundles.

Parameters

string $current_entity_type: The current entity type that these options will be used with.

string $current_bundle: The current bundle name that these options will be used with.

boolean $filter: Whether to filter out the current bundle.

Return value

An array for FormAPI '#options' properties, with:

  • keys of the form ENTITY:BUNDLE, using machine names.
  • values of the form ENTITY: BUNDLE, using labels.
2 calls to field_tools_options_entity_bundle()
field_tools_bundle_fields_clone_from_form in ./field_tools.admin.inc
Form builder for the cloning multiple fields from a bundle.
field_tools_field_clone_form in ./field_tools.admin.inc
Form builder for cloning a single field..

File

./field_tools.admin.inc, line 744
NOTICE: THIS FILE IS OBSOLETE. IT IS BEING KEPT UNTIL ALL FUNCTIONALITY IS PORTED TO DRUPAL 8.

Code

function field_tools_options_entity_bundle($current_entity_type, $current_bundle, $filter = TRUE) {
  $options = array();
  foreach (entity_get_info() as $entity_type => $entity_info) {

    // Skip entities that don't take fields.
    if (empty($entity_info['fieldable'])) {
      continue;
    }
    foreach ($entity_info['bundles'] as $bundle_type => $bundle_info) {

      // Don't show the current bundle in the options, unless not filtering.
      if (!$filter || !($current_entity_type == $entity_type && $bundle_type == $current_bundle)) {
        $options[$entity_type . ':' . $bundle_type] = $entity_info['label'] . ': ' . $bundle_info['label'];
      }
    }
  }
  return $options;
}