Skip to content
Snippets Groups Projects
Commit 76b8f62c authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2343943 by marcus7777, pp, alimac, pefferen | Greg Sims: Fixed Language...

Issue #2343943 by marcus7777, pp, alimac, pefferen | Greg Sims: Fixed Language domain may not be left blank for default language.
parent d3295bf1
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#tree' => TRUE,
'#title' => $this->t('Domain configuration'),
'#open' => TRUE,
'#description' => $this->t('The domain names to use for these languages. Leave blank for the default language. Use with caution in a production environment.<strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'),
'#description' => $this->t('The domain names to use for these languages. <strong>Modifying this value may break existing URLs. Use with caution in a production environment.</strong> Example: Specifying "de.example.com" as language domain for German will result in an URL like "http://de.example.com/contact".'),
'#states' => array(
'visible' => array(
':input[name="language_negotiation_url_part"]' => array(
......@@ -130,10 +130,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
$value = $form_state->getValue(array('domain', $langcode));
if ($value === '') {
if (!$language->isDefault() && $form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) {
if ($form_state->getValue('language_negotiation_url_part') == LanguageNegotiationUrl::CONFIG_DOMAIN) {
// Throw a form error if the domain is blank for a non-default language,
// although it is required for selected negotiation type.
$form_state->setErrorByName("domain][$langcode", $this->t('The domain may only be left blank for the default language.'));
$form_state->setErrorByName("domain][$langcode", $this->t('The domain may not be left blank for %language.', array('%language' => $language->name)));
}
}
elseif (isset($count[$value]) && $count[$value] > 1) {
......
......@@ -403,12 +403,23 @@ function testLanguageDomain() {
);
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Do not allow blank domain.
$edit = array(
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => '',
);
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText('The domain may not be left blank for English', 'The form does not allow blank domains.');
$this->rebuildContainer();
// Change the domain for the Italian language.
$edit = array(
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => gethostname(),
'domain[it]' => 'it.example.com',
);
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
$this->assertText('The configuration options have been saved', 'Domain configuration is saved.');
$this->rebuildContainer();
// Build the link we're going to test.
......
......@@ -101,6 +101,7 @@ function testDomainNameNegotiationPort() {
$language_domain = 'example.fr';
$edit = array(
'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domain[en]' => gethostname(),
'domain[fr]' => $language_domain
);
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment