diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index c8bd7bb..20d72ed 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -810,9 +810,9 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, a * Implements hook_form_FORM_ID_alter() for 'field_ui_field_instance_edit_form'. */ function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state, $form_id) { - if ($form['#instance']->isFieldTranslatable()) { + if ($form['#field']->isFieldTranslatable()) { module_load_include('inc', 'content_translation', 'content_translation.admin'); - $element = content_translation_field_sync_widget($form['#instance']); + $element = content_translation_field_sync_widget($form['#field']); if ($element) { $form['instance']['settings']['translation_sync'] = $element; } @@ -997,7 +997,7 @@ function content_translation_save_settings($settings) { // If the field does not have translatable enabled we need to reset // the sync settings to their defaults. else { - unset($instance['settings']['translation_sync']); + unset($instance->settings['translation_sync']); } $instance->save(); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php index c813790..9789dc5 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php @@ -34,7 +34,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase { * * @var array */ - public static $modules = array('language', 'content_translation', 'entity_test', 'image'); + public static $modules = array('language', 'content_translation', 'entity_test', 'image', 'field_ui'); public static function getInfo() { return array( @@ -80,9 +80,42 @@ protected function setupTestFields() { } /** + * {@inheritdoc} + */ + protected function getEditorPermissions() { + // Every entity-type-specific test needs to define these. + return array('administer entity_test_mul fields', 'administer languages', 'administer content translation'); + } + + /** * Tests image field field synchronization. */ function testImageFieldSync() { + // Check that the alt and title fields are enabled for the image field. + $this->drupalLogin($this->editor); + $this->drupalGet('entity_test_mul/structure/' . $this->entityType . '/fields/' . $this->entityType . '.' . $this->entityType . '.' . $this->fieldName); + $this->assertFieldChecked('edit-instance-settings-translation-sync-alt'); + $this->assertFieldChecked('edit-instance-settings-translation-sync-title'); + $edit = array( + 'instance[settings][translation_sync][alt]' => FALSE, + 'instance[settings][translation_sync][title]' => FALSE, + ); + $this->drupalPostForm(NULL, $edit, t('Save settings')); + + // Check that the content translation settings page reflects the changes + // performed in the field edit page. + $this->drupalGet('admin/config/regional/content-language'); + $this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); + $this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); + $edit = array( + 'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][alt]' => TRUE, + 'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][title]' => TRUE, + ); + $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save')); + $this->assertFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); + $this->assertFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); + $this->drupalLogin($this->translator); + $default_langcode = $this->langcodes[0]; $langcode = $this->langcodes[1]; diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php index 2081873..81c251d 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php @@ -35,7 +35,8 @@ * "uuid" = "uuid", * "bundle" = "type" * }, - * menu_base_path = "entity_test_mul/manage/%entity_test_mul" + * menu_base_path = "entity_test_mul/manage/%entity_test_mul", + * route_base_path = "entity_test_mul/structure/{bundle}" * ) */ class EntityTestMul extends EntityTest {