You are here

function entityreference_dragdrop_get_selected_options in Entity Reference Drag & Drop 7

Returns selected options.

1 call to entityreference_dragdrop_get_selected_options()
entityreference_dragdrop_field_widget_form in ./entityreference_dragdrop.module
Implements hook_field_widget_form().

File

./entityreference_dragdrop.module, line 207
Provides a Drag & Drop widget for entity-reference fields.

Code

function entityreference_dragdrop_get_selected_options($items, $options) {

  // Build an array of selected items in id => label format.
  $selected = array();
  foreach ($items as $item) {
    foreach ($options as $bundle => $entities) {
      if (array_key_exists($item['target_id'], $entities)) {
        $selected[$item['target_id']] = $entities[$item['target_id']];
      }
    }
  }
  return $selected;
}