diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 32808a43bebfee7d581903cdb32babb26de90000..1a7a1131ded3ebb1090d15275c642c90e9d507e9 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -778,18 +778,21 @@ function field_ui_formatter_options($field_type = NULL) { function field_ui_existing_field_options($obj_type, $bundle) { $options = array(); $field_types = field_info_field_types(); - foreach (field_info_instances($obj_type) as $bundle_name => $instances) { - // No need to look in the current bundle. - if ($bundle_name != $bundle) { - foreach ($instances as $instance) { - $field = field_info_field($instance['field_name']); - // Don't show locked fields or fields already in the current bundle. - if (empty($field['locked']) && !field_info_instance($obj_type, $field['field_name'], $bundle)) { - $text = t('@type: @field (@label)', array( - '@type' => $field_types[$field['type']]['label'], - '@label' => t($instance['label']), '@field' => $instance['field_name'], - )); - $options[$instance['field_name']] = (drupal_strlen($text) > 80 ? truncate_utf8($text, 77) . '...' : $text); + + foreach (field_info_instances() as $existing_obj_type => $bundles) { + foreach ($bundles as $existing_bundle => $instances) { + // No need to look in the current bundle. + if (!($existing_bundle == $bundle && $existing_obj_type == $obj_type)) { + foreach ($instances as $instance) { + $field = field_info_field($instance['field_name']); + // Don't show locked fields or fields already in the current bundle. + if (empty($field['locked']) && !field_info_instance($obj_type, $field['field_name'], $bundle)) { + $text = t('@type: @field (@label)', array( + '@type' => $field_types[$field['type']]['label'], + '@label' => t($instance['label']), '@field' => $instance['field_name'], + )); + $options[$instance['field_name']] = (drupal_strlen($text) > 80 ? truncate_utf8($text, 77) . '...' : $text); + } } } } diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index 0c2dde897c192f18de575523db4d9c750f9c7a5b..a858ed47a1929700e3772ccdb2ec70da47b110d6 100644 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -20,7 +20,7 @@ class FieldUITestCase extends DrupalWebTestCase { function setUp() { parent::setUp('field_test'); - $admin_user = $this->drupalCreateUser(array('access content', 'administer content types')); + $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); $this->drupalLogin($admin_user); // Create content type, with underscores. $type_name = strtolower($this->randomName(8)) . '_' .'test'; @@ -102,6 +102,12 @@ class FieldUITestCase extends DrupalWebTestCase { // Assert redirection back the to "manage fields" page. $this->assertText(t('Saved @label configuration.', array('@label' => $this->field_label)), t('Redirected to "Manage fields" page.')); $this->assertText($this->field_name, t('Field was created and appears in overview page.')); + + // Assert the field appears in the "add existing field" section for + // different entity types; e.g. if a field was added in a node entity, it + // should also appear in the 'taxonomy term' entity. + $this->drupalGet('admin/structure/taxonomy/1/fields'); + $this->assertTrue($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value="' . $this->field_name . '"]'), t('Existing field was found in account settings.')); } /**