diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-11 06:58:24 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-11 06:58:24 +0000 |
commit | 161e790e2098ac655a3b42168f86bb12f448f2e5 (patch) | |
tree | 9bf824722914361bed5adbd2e9da0dcaf5053236 /modules | |
parent | 6f2a878ffe1bd453055f485ae888e20b035e5ac4 (diff) | |
download | brdo-161e790e2098ac655a3b42168f86bb12f448f2e5.tar.gz brdo-161e790e2098ac655a3b42168f86bb12f448f2e5.tar.bz2 |
#626664 by yched, Amitaibu: Fixed 'Add existing field' in user doesn't show fields created in content types.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/field_ui/field_ui.admin.inc | 27 | ||||
-rw-r--r-- | modules/field_ui/field_ui.test | 8 |
2 files changed, 22 insertions, 13 deletions
diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 32808a43b..1a7a1131d 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 0c2dde897..a858ed47a 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.')); } /** |