Commit 9e695889 authored by alexpott's avatar alexpott

Issue #2470307 by Mark_L6n, eiriksm, Gábor Hojtsy: Modifying path prefix for...

Issue #2470307 by Mark_L6n, eiriksm, Gábor Hojtsy: Modifying path prefix for URL language detection causes error message for default language
parent f52cc182
......@@ -6,3 +6,4 @@ url:
en: ''
domains:
en: ''
selected_langcode: site_default
......@@ -153,7 +153,9 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
if (!($default_langcode == $langcode) && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
// Throw a form error if the prefix is blank for a non-default language,
// although it is required for selected negotiation type.
$form_state->setErrorByName("prefix][$langcode", $this->t('The prefix may only be left blank for the selected detection fallback language.'));
$form_state->setErrorByName("prefix][$langcode", $this->t('The prefix may only be left blank for the <a href="@url">selected detection fallback language.</a>', [
'@url' => $this->getUrlGenerator()->generate('language.negotiation_selected'),
]));
}
}
elseif (strpos($value, '/') !== FALSE) {
......
......@@ -91,6 +91,12 @@ function testLanguageConfiguration() {
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'french', 'French path prefix has changed.');
// Check that the prefix can be removed.
$edit = array(
'prefix[fr]' => '',
);
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->assertNoText(t('The prefix may only be left blank for the selected detection fallback language.'), 'The path prefix can be removed for the default language');
// Change default negotiation language.
$this->config('language.negotiation')->set('selected_langcode', 'fr')->save();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment