Issue #2746253 by borisson_, Leksat, eiriksm, alexpott: Configuration translation save triggers an undefined index notice
parent
a9fe99c7cb
commit
240524f08c
|
@ -197,7 +197,7 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
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 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
$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\FieldConfig;
|
|||
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 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue