entityreference_dragdrop.module in Entity Reference Drag & Drop 8
File
entityreference_dragdrop.module
View source
<?php
use Drupal\Core\Template\Attribute;
function entityreference_dragdrop_theme($existing, $type, $theme, $path) {
return [
'entityreference_dragdrop_options_list' => [
'variables' => [
'items' => [],
'title' => '',
'wrapper_attributes' => [],
'attributes' => [],
'display_filter' => 0,
],
],
];
}
function template_preprocess_entityreference_dragdrop_options_list(&$variables) {
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
foreach ($variables['items'] as &$item) {
$attributes = [];
if (is_array($item)) {
if (isset($item['#wrapper_attributes'])) {
$attributes = $item['#wrapper_attributes'];
}
}
$item = [
'value' => $item,
'attributes' => new Attribute($attributes),
];
}
$variables['filter'] = !$variables['display_filter'] ? [] : [
'#type' => 'textfield',
'#attributes' => [
'class' => [
'entityreference-dragdrop-filter',
],
],
];
}