function template_preprocess_entityreference_dragdrop_options_list in Entity Reference Drag & Drop 2.x
Same name and namespace in other branches
- 8 entityreference_dragdrop.module \template_preprocess_entityreference_dragdrop_options_list()
Prepares variables for entityreference_dragdrop options list template.
Parameters
array $variables:
File
- ./
entityreference_dragdrop.module, line 27
Code
function template_preprocess_entityreference_dragdrop_options_list(&$variables) {
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
foreach ($variables['items'] as &$item) {
$attributes = [];
// If the item value is an array, then it is a render array.
if (is_array($item)) {
// List items support attributes via the '#wrapper_attributes' property.
if (isset($item['#wrapper_attributes'])) {
$attributes = $item['#wrapper_attributes'];
}
}
// Set the item's value and attributes for the template.
$item = [
'value' => $item,
'attributes' => new Attribute($attributes),
];
}
$variables['filter'] = !$variables['display_filter'] ? [] : [
'#type' => 'textfield',
'#attributes' => [
'class' => [
'entityreference-dragdrop-filter',
],
],
];
}