function theme_entityreference_view_widget_selected_items in Entity Reference View Widget 7
Returns HTML for the selected entities (usually displaed in the left sidebar). By default it adds tabledrag functionality.
Parameters
$variables: An associative array containing:
- element: A render element representing the widgets.
File
- ./
entityreference_view_widget.module, line 420
Code
function theme_entityreference_view_widget_selected_items($variables) {
$element = $variables['element'];
// Special ID and classes for draggable tables.
$weight_class = $element['#id'] . '-weight';
$table_id = $element['#id'] . '-table';
// Get our list of widgets in order (needed when the form comes back after
// preview or failed validation).
$widgets = array();
foreach (element_children($element) as $key) {
$widgets[] =& $element[$key];
}
usort($widgets, '_field_sort_items_value_helper');
$rows = array();
foreach ($widgets as $key => &$widget) {
// Render the weight element.
$widget['_weight']['#attributes']['class'] = array(
$weight_class,
);
$weight = render($widget['_weight']);
// Render everything else (the renderable array returned by entity_view()).
$widget['#theme_wrappers'] = array();
$information = drupal_render($widget);
$rows[] = array(
'data' => array(
$information,
$weight,
),
'class' => isset($widget['#attributes']['class']) ? array_merge($widget['#attributes']['class'], array(
'draggable',
)) : array(
'draggable',
),
'no_striping' => TRUE,
);
}
drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class);
$output = empty($rows) ? '' : theme('table', array(
'header' => array(),
'rows' => $rows,
'attributes' => array(
'id' => $table_id,
),
));
$output .= drupal_render_children($element);
return $output;
}