diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index 5d46ebe..25c168f 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -177,7 +177,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t } // Field label and field_name. - $form['naming_wrapper'] = array( + $form['name_wrapper'] = array( '#type' => 'container', '#states' => array( '!visible' => array( @@ -187,7 +187,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ), ); - $form['naming_wrapper']['label'] = array( + $form['name_wrapper']['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), '#size' => 15, @@ -195,7 +195,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ); $field_prefix = $this->config('field_ui.settings')->get('field_prefix'); - $form['naming_wrapper']['field_name'] = array( + $form['name_wrapper']['field_name'] = array( '#type' => 'machine_name', // This field should stay LTR even for RTL languages. '#field_prefix' => '' . $field_prefix, @@ -206,7 +206,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t // setting. Maximum length is 32. '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix), '#machine_name' => array( - 'source' => array('naming_wrapper', 'label'), + 'source' => array('name_wrapper', 'label'), 'exists' => array($this, 'fieldNameExists'), ), '#required' => FALSE, @@ -275,7 +275,7 @@ protected function validateAddNew(array $form, FormStateInterface $form_state) { // Add the field prefix. $field_name = $this->configFactory->get('field_ui.settings')->get('field_prefix') . $field_name; - $form_state->setValueForElement($form['naming_wrapper']['field_name'], $field_name); + $form_state->setValueForElement($form['name_wrapper']['field_name'], $field_name); } } } @@ -293,7 +293,7 @@ protected function validateAddNew(array $form, FormStateInterface $form_state) { protected function validateAddExisting(array $form, FormStateInterface $form_state) { if ($form_state->getValue('existing_field_name')) { // Discard any value that might be set for the field name. - $form_state->setValueForElement($form['naming_wrapper']['field_name'], ''); + $form_state->setValueForElement($form['name_wrapper']['field_name'], ''); } } diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index f384596..9ae89b8 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -182,7 +182,7 @@ function addExistingField() { // do not show up in the "Re-use existing field" list. $this->assertFalse($this->xpath('//select[@id="edit-existing-field-name"]//option[@value="comment"]'), 'The list of options respects entity type restrictions.'); // Validate the FALSE assertion above by also testing a valid one. - $this->assertTrue($this->xpath('//select[@id="edit-existing-field-name"]//option[@value="' . $this->field_name . '"]'), 'The list of options shows a valid option.'); + $this->assertTrue($this->xpath('//select[@id="edit-existing-field-name"]//option[@value=:field_name]', array(':field_name' => $this->field_name)), 'The list of options shows a valid option.'); // Add a new field based on an existing field. $this->fieldUIAddExistingField("admin/structure/types/manage/page", $this->field_name, $this->field_label . '_2'); @@ -469,6 +469,7 @@ function testHiddenFields() { // Check that the field type is not available in the 'add new field' row. $this->drupalGet('admin/structure/types/manage/' . $this->type . '/add-field'); $this->assertFalse($this->xpath('//select[@id="edit-type"]//option[@value="hidden_test_field"]'), "The 'add new field' select respects field types 'no_ui' property."); + $this->assertTrue($this->xpath('//select[@id="edit-type"]//option[@value="shape"]'), "The 'add new field' select shows a valid option."); // Create a field storage and a field programmatically. $field_name = 'hidden_test_field'; @@ -496,8 +497,9 @@ function testHiddenFields() { // Check that the field does not appear in the 're-use existing field' row // on other bundles. - $this->drupalGet('admin/structure/types/manage/article/add-field'); - $this->assertFalse($this->xpath('//select[@id="edit-existing-field"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 're-use existing field' select respects field types 'no_ui' property."); + $this->drupalGet('admin/structure/types/manage/page/add-field'); + $this->assertFalse($this->xpath('//select[@id="edit-existing-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 're-use existing field' select respects field types 'no_ui' property."); + $this->assertTrue($this->xpath('//select[@id="edit-existing-field-name"]//option[@value=:field_name]', array(':field_name' => 'field_tags')), "The 're-use existing field' select shows a valid option."); // Check that non-configurable fields are not available. $field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();