function LanguageSelectWidget::formElement

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget::formElement()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget::formElement()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget::formElement()

Overrides WidgetInterface::formElement

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php, line 25

Class

LanguageSelectWidget
Plugin implementation of the 'Language' widget.

Namespace

Drupal\Core\Field\Plugin\Field\FieldWidget

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.