diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index fb015c7..088d6af 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -165,7 +165,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { public function afterBuild(array $element, FormStateInterface $form_state) { // Rebuild the entity if #after_build is being called as part of a form // rebuild, i.e. if we are processing input. - if ($form_state->isProcessingInput()) { + if ($form_state->isRebuilding() && $form_state->isProcessingInput()) { $this->entity = $this->buildEntity($element, $form_state); } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 93d73f9..474af56 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -318,13 +318,13 @@ function content_translation_entity_extra_field_info() { } /** - * Implements hook_form_FORM_ID_alter() for 'field_ui_field_edit_form'. + * Implements hook_form_FORM_ID_alter() for 'field_config_edit_form'. */ -function content_translation_form_field_ui_field_edit_form_alter(array &$form, FormStateInterface $form_state) { - $field = $form_state->get('field'); +function content_translation_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) { + $field = $form_state->getFormObject()->getEntity(); $bundle_is_translatable = \Drupal::service('content_translation.manager')->isEnabled($field->entity_type, $field->bundle); - $form['field']['translatable'] = array( + $form['translatable'] = array( '#type' => 'checkbox', '#title' => t('Users may translate this field'), '#default_value' => $field->isTranslatable(), @@ -338,7 +338,7 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, F $toggle_url = \Drupal::url('language.content_settings_page', array(), array( 'query' => drupal_get_destination(), )); - $form['field']['translatable']['#description'] = t('To configure translation for this field, enable language support for this type.', array( + $form['translatable']['#description'] = t('To configure translation for this field, enable language support for this type.', array( '@language-settings-url' => $toggle_url, )); } @@ -347,8 +347,8 @@ function content_translation_form_field_ui_field_edit_form_alter(array &$form, F module_load_include('inc', 'content_translation', 'content_translation.admin'); $element = content_translation_field_sync_widget($field); if ($element) { - $form['field']['third_party_settings']['content_translation']['translation_sync'] = $element; - $form['field']['third_party_settings']['content_translation']['translation_sync']['#weight'] = -10; + $form['third_party_settings']['content_translation']['translation_sync'] = $element; + $form['third_party_settings']['content_translation']['translation_sync']['#weight'] = -10; } } } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php index 9874574..4fc4094 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php @@ -174,7 +174,7 @@ function testSettingsUI() { // Test that also the Field UI form behaves correctly. $translatable = !$translatable; - $edit = array('field[translatable]' => $translatable); + $edit = array('translatable' => $translatable); $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings')); \Drupal::entityManager()->clearCachedFieldDefinitions(); $field = FieldConfig::loadByName('node', 'article', 'body'); @@ -242,7 +242,7 @@ function testFieldTranslatableSettingsUI() { // translatable. $path = 'admin/structure/types/manage/article/fields/node.article.field_article_text'; $this->drupalGet($path); - $this->assertFieldByXPath('//input[@id="edit-field-translatable" and @disabled="disabled"]'); + $this->assertFieldByXPath('//input[@id="edit-translatable" and @disabled="disabled"]'); $this->assertText('To configure translation for this field, enable language support for this type.', 'No translatable setting for field.'); // Tests that field has translatable setting if bundle is translatable. @@ -255,7 +255,7 @@ function testFieldTranslatableSettingsUI() { ); $this->assertSettings('node', 'article', TRUE, $edit); $this->drupalGet($path); - $this->assertFieldByXPath('//input[@id="edit-field-translatable" and not(@disabled) and @checked="checked"]'); + $this->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]'); $this->assertNoText('To enable translation of this field, enable language support for this type.', 'Translatable setting for field available.'); } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php index cbae0d4..f1b7688 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php @@ -88,11 +88,11 @@ 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->entityTypeId . '/fields/' . $this->entityTypeId . '.' . $this->entityTypeId . '.' . $this->fieldName); - $this->assertFieldChecked('edit-field-third-party-settings-content-translation-translation-sync-alt'); - $this->assertFieldChecked('edit-field-third-party-settings-content-translation-translation-sync-title'); + $this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt'); + $this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title'); $edit = array( - 'field[third_party_settings][content_translation][translation_sync][alt]' => FALSE, - 'field[third_party_settings][content_translation][translation_sync][title]' => FALSE, + 'third_party_settings[content_translation][translation_sync][alt]' => FALSE, + 'third_party_settings[content_translation][translation_sync][title]' => FALSE, ); $this->drupalPostForm(NULL, $edit, t('Save settings')); diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php index c1542f1..8ee3a26 100644 --- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php @@ -76,21 +76,23 @@ public function form(array $form, FormStateInterface $form_state) { '#weight' => -5, ); - // Add field settings for the field type and a container for third party - // settings that modules can add to via hook_form_FORM_ID_alter(). // Create an arbitrary entity object (used by the 'default value' widget). $ids = (object) array('entity_type' => $this->entity->getTargetEntityTypeId(), 'bundle' => $this->entity->bundle, 'entity_id' => NULL); $form['#entity'] = _field_create_entity_from_ids($ids); $items = $form['#entity']->get($this->entity->getName()); $item = $items->first() ?: $items->appendItem(); + // Add field settings for the field type and a container for third party + // settings that modules can add to via hook_form_FORM_ID_alter(). $form['settings'] = array( '#tree' => TRUE, '#weight' => 10, ); $form['settings'] += $item->fieldSettingsForm($form, $form_state); - $form['third_party_settings'] = array(); - $form['third_party_settings']['#weight'] = 11; + $form['third_party_settings'] = array( + '#tree' => TRUE, + '#weight' => 11, + ); // Add handling for default value. if ($element = $items->defaultValuesForm($form, $form_state)) { @@ -98,6 +100,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'details', '#title' => $this->t('Default value'), '#open' => TRUE, + '#tree' => TRUE, '#description' => $this->t('The default value for this field, used when creating new content.'), )); diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php index b7d4350..215794a 100644 --- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php @@ -293,7 +293,7 @@ public function testDefaultImages() { ); $non_image = $this->drupalGetTestFiles('text'); - $this->drupalPostForm(NULL, array('files[field_settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload")); + $this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload")); $this->assertText(t('The specified file text-0.txt could not be uploaded. Only files with the following extensions are allowed: png gif jpg jpeg.'), 'Non-image file cannot be used as default image.'); // Confirm the default image is shown on the node form. diff --git a/core/modules/link/src/Tests/LinkFieldUITest.php b/core/modules/link/src/Tests/LinkFieldUITest.php index 97fd9c8..d9531ce 100644 --- a/core/modules/link/src/Tests/LinkFieldUITest.php +++ b/core/modules/link/src/Tests/LinkFieldUITest.php @@ -85,7 +85,7 @@ function testFieldUI() { // external only links. $label = $this->randomMachineName(); $field_name = Unicode::strtolower($label); - $field_edit = ['field[settings][link_type]' => LinkItemInterface::LINK_EXTERNAL]; + $field_edit = ['settings[link_type]' => LinkItemInterface::LINK_EXTERNAL]; $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', array(), $field_edit); // Test the help text displays when link allows only external links.