Commit 240524f0 authored by alexpott's avatar alexpott

Issue #2746253 by borisson_, Leksat, eiriksm, alexpott: Configuration...

Issue #2746253 by borisson_, Leksat, eiriksm, alexpott: Configuration translation save triggers an undefined index notice
parent a9fe99c7
......@@ -197,7 +197,7 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state->getValue(['translation', 'config_names']);
foreach ($this->mapper->getConfigNames() as $name) {
foreach ($form_values as $name => $value) {
$schema = $this->typedConfigManager->get($name);
// Set configuration values based on form submission and source values.
......@@ -205,7 +205,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name);
$element = $this->createFormElement($schema);
$element->setConfig($base_config, $config_translation, $form_values[$name]);
$element->setConfig($base_config, $config_translation, $value);
// If no overrides, delete language specific configuration file.
$saved_config = $config_translation->get();
......
......@@ -12,6 +12,7 @@
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
/**
......@@ -1033,6 +1034,45 @@ public function testTextFormatTranslation() {
$this->assertEqual($expected, $actual);
}
/**
* Tests field translation for node fields.
*/
public function testNodeFieldTranslation() {
NodeType::create(['type' => 'article', 'name' => 'Article'])->save();
$field_name = 'translatable_field';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
]);
$field_storage->setSetting('translatable_storage_setting', 'translatable_storage_setting');
$field_storage->save();
$field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'article',
]);
$field->save();
$this->drupalLogin($this->translatorUser);
$this->drupalGet("/entity_test/structure/article/fields/node.article.$field_name/translate");
$this->clickLink('Add');
$form_values = [
'translation[config_names][field.field.node.article.translatable_field][description]' => 'FR Help text.',
'translation[config_names][field.field.node.article.translatable_field][label]' => 'FR label',
];
$this->drupalPostForm(NULL, $form_values, 'Save translation');
$this->assertText('Successfully saved French translation.');
// Check that the translations are saved.
$this->clickLink('Add');
$this->assertRaw('FR label');
}
/**
* Gets translation from locale storage.
*
......
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