Implements hook_options_list().
function entity_reference_options_list($field, $instance, $entity_type = NULL, $entity = NULL) {
if (!($options = entity_reference_get_selection_handler($field, $instance, $entity)
->getReferencableEntities())) {
return array();
}
// Rebuild the array by changing the bundle key into the bundle label.
$target_type = $field['settings']['target_type'];
$bundles = entity_get_bundles($target_type);
$return = array();
foreach ($options as $bundle => $entity_ids) {
$bundle_label = check_plain($bundles[$bundle]['label']);
$return[$bundle_label] = $entity_ids;
}
return count($return) == 1 ? reset($return) : $return;
}