
Index: modules/field_ui/field_ui.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v
retrieving revision 1.57
diff -u -r1.57 field_ui.admin.inc
--- modules/field_ui/field_ui.admin.inc	27 Jun 2010 18:05:54 -0000	1.57
+++ modules/field_ui/field_ui.admin.inc	17 Jul 2010 15:39:11 -0000
@@ -463,8 +463,20 @@
   // Add settings for the update selects behavior.
   $js_fields = array();
   foreach ($existing_field_options as $field_name => $fields) {
+    if ($field_name === 0) continue;
+
     $field = field_info_field($field_name);
-    $instance = field_info_instance($form['#entity_type'], $field_name, $form['#bundle']);
+    if (isset($field['bundles'][$form['#entity_type']]) && is_array($field['bundles'][$form['#entity_type']])) {
+      // Get the last existing instance of the same entity type, like
+      // field_ui_existing_field_options() does.
+      $instance = field_info_instance($form['#entity_type'], $field_name, array_pop($field['bundles'][$form['#entity_type']]));
+    }
+    else {
+      $existing_field_entity_types = array_keys($field['bundles']);
+      $existing_field_entity_type = array_pop($existing_field_entity_types);
+      // Get the last existing instance of the last available entity type.
+      $instance = field_info_instance($existing_field_entity_type, $field_name, array_pop($field['bundles'][$existing_field_entity_type]));
+    }
     $js_fields[$field_name] = array('label' => $instance['label'], 'type' => $field['type'], 'widget' => $instance['widget']['type']);
   }
 
