diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index 42eb11e..62a38bd 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -79,7 +79,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $form['test_field_storage_setting'] = array( + $element['test_field_storage_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field storage setting'), '#default_value' => $this->getSetting('test_field_storage_setting'), @@ -87,14 +87,14 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state '#description' => t('A dummy form element to simulate field storage setting.'), ); - return $form; + return $element; } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { - $form['test_field_setting'] = array( + $element['test_field_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field setting'), '#default_value' => $this->getSetting('test_field_setting'), @@ -102,7 +102,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#description' => t('A dummy form element to simulate field setting.'), ); - return $form; + return $element; } /** diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index 064e54f..e5f15ea 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -169,9 +169,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t // New field storage subform wrapper. $form['new_storage_wrapper'] = [ '#type' => 'container', - '#attributes' => [ - 'id' => 'new-storage-wrapper', - ], + '#id' => 'new-storage-wrapper', ]; if ($form_state->isRebuilding() && ($new_storage_type = $form_state->getValue('new_storage_type'))) { @@ -236,7 +234,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t $field_storage_form = $form_object->form([], $form_state); unset($field_storage_form['#process'], $field_storage_form['#after_build']); - $field_storage_form['cardinality_container']['#parents'] = ['new_storage_wrapper']; + foreach (Element::children($field_storage_form) as $key) { + $field_storage_form[$key]['#parents'] = ['new_storage_wrapper']; + } $form['new_storage_wrapper'] += $field_storage_form; } diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index 8cc6e43..056cae2 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -353,11 +353,13 @@ function testFieldPrefix() { $field_exceed_max_length_input = $this->randomMachineName(23); // Try to create the field. + $this->drupalPostAjaxForm('admin/structure/types/manage/' . $this->contentType . '/fields/add-field', ['new_storage_type' => 'test_field'], 'new_storage_type'); $edit = array( + 'new_storage_type' => 'test_field', 'label' => $field_exceed_max_length_label, 'field_name' => $field_exceed_max_length_input, ); - $this->drupalPostForm('admin/structure/types/manage/' . $this->contentType . '/fields/add-field', $edit, t('Save and continue')); + $this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->assertText('Machine-readable name cannot be longer than 22 characters but is currently 23 characters long.'); // Create a valid field. @@ -483,6 +485,9 @@ function testDisallowedFieldNames() { // Reset the field prefix so we can test properly. $this->config('field_ui.settings')->set('field_prefix', '')->save(); + $bundle_path = 'admin/structure/types/manage/' . $this->contentType; + $this->drupalPostAjaxForm("$bundle_path/fields/add-field", ['new_storage_type' => 'test_field'], 'new_storage_type'); + $label = 'Disallowed field'; $edit = array( 'label' => $label, @@ -491,14 +496,12 @@ function testDisallowedFieldNames() { // Try with an entity key. $edit['field_name'] = 'title'; - $bundle_path = 'admin/structure/types/manage/' . $this->contentType; - $this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue')); + $this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->assertText(t('The machine-readable name is already in use. It must be unique.')); // Try with a base field. $edit['field_name'] = 'sticky'; - $bundle_path = 'admin/structure/types/manage/' . $this->contentType; - $this->drupalPostForm("$bundle_path/fields/add-field", $edit, t('Save and continue')); + $this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->assertText(t('The machine-readable name is already in use. It must be unique.')); } @@ -596,13 +599,14 @@ function testHiddenFields() { function testDuplicateFieldName() { // field_tags already exists, so we're expecting an error when trying to // create a new field with the same name. + $url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field'; + $this->drupalPostAjaxForm($url, ['new_storage_type' => 'entity_reference'], 'new_storage_type'); $edit = array( 'field_name' => 'tags', 'label' => $this->randomMachineName(), 'new_storage_type' => 'entity_reference', ); - $url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field'; - $this->drupalPostForm($url, $edit, t('Save and continue')); + $this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->assertText(t('The machine-readable name is already in use. It must be unique.')); $this->assertUrl($url, array(), 'Stayed on the same page.'); diff --git a/core/modules/file/src/Tests/FileFieldDisplayTest.php b/core/modules/file/src/Tests/FileFieldDisplayTest.php index aa4923c..bce01b6 100644 --- a/core/modules/file/src/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/src/Tests/FileFieldDisplayTest.php @@ -144,13 +144,14 @@ function testDescToggle() { 'type' => $type_name, ); $this->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields')); + + $this->drupalPostAjaxForm('/admin/structure/types/manage/' . $type_name . '/fields/add-field', ['new_storage_type' => $field_type], 'new_storage_type'); $edit = array( 'new_storage_type' => $field_type, 'field_name' => $field_name, 'label' => $this->randomString(), ); - $this->drupalPostForm('/admin/structure/types/manage/' . $type_name . '/fields/add-field', $edit, t('Save and continue')); - $this->drupalPostForm(NULL, array(), t('Save field settings')); + $this->drupalPostForm(NULL, $edit, t('Save and continue')); // Ensure the description field is selected on the field instance settings // form. That's what this test is all about. $edit = array( diff --git a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php index 6a74718..9c9e859 100644 --- a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php +++ b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php @@ -143,16 +143,13 @@ public function testSearchTagsBubbling() { $this->drupalLogin($admin_user); // First step: 'Add new field' on the 'Manage fields' page. - $this->drupalGet($bundle_path . '/fields/add-field'); + $this->drupalPostAjaxForm($bundle_path . '/fields/add-field', ['new_storage_type' => 'entity_reference'], 'new_storage_type'); $this->drupalPostForm(NULL, [ 'label' => 'Test label', 'field_name' => 'test__ref', 'new_storage_type' => 'entity_reference', ], t('Save and continue')); - // Second step: 'Field settings' form. - $this->drupalPostForm(NULL, [], t('Save field settings')); - // Create a new node of our newly created node type and fill in the entity // reference field. $edit = [