Commit 161e790e authored by webchick's avatar webchick
Browse files

#626664 by yched, Amitaibu: Fixed 'Add existing field' in user doesn't show...

#626664 by yched, Amitaibu: Fixed 'Add existing field' in user doesn't show fields created in content types.
parent 6f2a878f
......@@ -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);
}
}
}
}
......
......@@ -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.'));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment