Problem/Motivation
The following code reads settings from where it should be but then saves to somewhere else in NegotiationSessionForm.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.
Comments
Comment #1
gábor hojtsyFix is easy. Needs tests.
Comment #2
wim leersHah!
Comment #3
penyaskitoAdded tests for session negotiation. Tests this issue as a side effect.
Comment #4
penyaskitoForgot to add ::runTest() to the patch.
Comment #8
gábor hojtsyYay, amazing. Thanks for these tests.
The assert messages are backwards? Need to be flipped.
Comment #9
penyaskitoOops, sorry.
(╯°□°)╯︵ ┻━┻
Fixed.
Comment #10
gábor hojtsyLooks great, thanks a lot!
Comment #12
alexpottCommitted 455a6a6 and pushed to 8.0.x. Thanks!
Comment #14
gábor hojtsyYay, thanks all!