protected function Select2BoxesAutocompleteListWidget::setLanguagesList in Select2 Boxes 8
Specifies the languages list options if needed.
1 call to Select2BoxesAutocompleteListWidget::setLanguagesList()
- Select2BoxesAutocompleteListWidget::formElement in src/
Plugin/ Field/ FieldWidget/ Select2BoxesAutocompleteListWidget.php - Returns the form for a single field widget.
File
- src/
Plugin/ Field/ FieldWidget/ Select2BoxesAutocompleteListWidget.php, line 132
Class
- Select2BoxesAutocompleteListWidget
- Class Select2BoxesAutocompleteList.
Namespace
Drupal\select2boxes\Plugin\Field\FieldWidgetCode
protected function setLanguagesList() {
if (!isset($this->options)) {
// Specify the default "none" option in case of using single-value widget.
$this->options = [
'_none' => $this
->t('- None -'),
];
// Add the languages list using language manager service.
$this->options += array_map(function ($language) {
/** @var \Drupal\Core\Language\LanguageInterface $language */
return $language
->getName();
}, \Drupal::languageManager()
->getLanguages());
}
}