class LanguageSelectWidget
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget
Plugin implementation of the 'Language' widget.
Plugin annotation
@FieldWidget(
id = "language_select",
label = @Translation("Language select"),
field_types = {
"language"
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Field\WidgetBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\WidgetInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget extends \Drupal\Core\Field\WidgetBase
- class \Drupal\Core\Field\WidgetBase extends \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\WidgetInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface
- class \Drupal\Core\Field\PluginSettingsBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of LanguageSelectWidget
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldWidget/ LanguageSelectWidget.php, line 21
Namespace
Drupal\Core\Field\Plugin\Field\FieldWidgetView source
class LanguageSelectWidget extends WidgetBase {
/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'language_select',
'#default_value' => $items[$delta]->value,
'#languages' => $this->getSetting('include_locked') ? LanguageInterface::STATE_ALL : LanguageInterface::STATE_CONFIGURABLE,
];
return $element;
}
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
$settings = parent::defaultSettings();
$settings['include_locked'] = TRUE;
return $settings;
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$element['include_locked'] = [
'#type' => 'checkbox',
'#title' => $this->t('Include locked languages such as <em>Not specified</em> and <em>Not applicable</em>'),
'#default_value' => $this->getSetting('include_locked'),
];
return $element;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.