Problem/Motivation
The following code reads settings from where it should be but then saves to somewhere else in NegotiationSessionForm.php:
<?php
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
$form['language_negotiation_session_param'] = array(
'#title'=> $this->t('Request/session parameter'),
'#type'=> 'textfield',
'#default_value'=> $config->get('session.parameter'),
'#description'=> $this->t('Name of the request/session parameter used to determine the desired language.'),
);
$form_state->setRedirect('language.negotiation');
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.settings')
->set('session.parameter', $form_state->getValue('language_negotiation_session_param'))
->save();
parent::submitForm($form, $form_state);
}
?>
Proposed resolution
Save to the right place.
Add tests.
Remaining tasks
Add tests.
User interface changes
None.
API changes
None.