protected function EntityReferenceDragDropWidget::getAvailableOptions in Entity Reference Drag & Drop 2.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php \Drupal\entityreference_dragdrop\Plugin\Field\FieldWidget\EntityReferenceDragDropWidget::getAvailableOptions()
Gets a list of available entities for the field.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items:
Return value
array
1 call to EntityReferenceDragDropWidget::getAvailableOptions()
- EntityReferenceDragDropWidget::formElement in src/
Plugin/ Field/ FieldWidget/ EntityReferenceDragDropWidget.php - Returns the form for a single field widget.
File
- src/
Plugin/ Field/ FieldWidget/ EntityReferenceDragDropWidget.php, line 224
Class
- EntityReferenceDragDropWidget
- Plugin implementation of the 'entityreference_dragdrop' widget.
Namespace
Drupal\entityreference_dragdrop\Plugin\Field\FieldWidgetCode
protected function getAvailableOptions(FieldItemListInterface $items) {
// We need to check against a flat list of options.
$flat_options = OptGroup::flattenOptions($this
->getOptions($items
->getEntity()));
$selected_options = $this
->getSelectedOptions($items);
$available_options = [];
foreach ($flat_options as $id => $option) {
if (!in_array($option, $selected_options)) {
$available_options[$id] = $option;
}
}
return $available_options;
}