protected function DropdownWidgetType::getSelectedOptions in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.2 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.3 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.4 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.5 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.6 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.7 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 8.8 modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 10.3.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 10.0.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 10.1.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
- 10.2.x modules/custom/dropdown/src/Plugin/Field/FieldWidget/DropdownWidgetType.php \Drupal\dropdown\Plugin\Field\FieldWidget\DropdownWidgetType::getSelectedOptions()
Determines selected options from the incoming field values.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values.
int $delta: (optional) The delta of the item to get options for. Defaults to 0.
Return value
array The array of corresponding selected options.
File
- modules/
custom/ dropdown/ src/ Plugin/ Field/ FieldWidget/ DropdownWidgetType.php, line 152
Class
- DropdownWidgetType
- Plugin implementation of the 'dropdown_widget_type' widget.
Namespace
Drupal\dropdown\Plugin\Field\FieldWidgetCode
protected function getSelectedOptions(FieldItemListInterface $items, $delta = 0) {
// We need to check against a flat list of options.
$options = $this
->getOptions($items
->getEntity());
$selected_options = [];
foreach ($items as $item) {
$value = $item->{$this->column};
// Keep the value if it actually is in the list of options (needs to be
// checked against the flat list).
if (isset($options[$value])) {
$selected_options[] = $value;
}
}
return $selected_options;
}