class NegotiationSelectedForm
Same name and namespace in other branches
- 10 core/modules/language/src/Form/NegotiationSelectedForm.php \Drupal\language\Form\NegotiationSelectedForm
- 11.x core/modules/language/src/Form/NegotiationSelectedForm.php \Drupal\language\Form\NegotiationSelectedForm
- 8.9.x core/modules/language/src/Form/NegotiationSelectedForm.php \Drupal\language\Form\NegotiationSelectedForm
Configure the selected language negotiation method for this site.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait extends \Drupal\Core\Form\FormBase
- class \Drupal\language\Form\NegotiationSelectedForm extends \Drupal\Core\Form\ConfigFormBase
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of NegotiationSelectedForm
1 string reference to 'NegotiationSelectedForm'
- language.routing.yml in core/
modules/ language/ language.routing.yml - core/modules/language/language.routing.yml
File
-
core/
modules/ language/ src/ Form/ NegotiationSelectedForm.php, line 14
Namespace
Drupal\language\FormView source
class NegotiationSelectedForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'language_negotiation_configure_selected_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'language.negotiation',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
$form['selected_langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Language'),
'#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT,
'#default_value' => $config->get('selected_langcode'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.negotiation')
->set('selected_langcode', $form_state->getValue('selected_langcode'))
->save();
parent::submitForm($form, $form_state);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.