Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.513
diff -u -p -r1.513 form.inc
--- includes/form.inc	30 Nov 2010 17:16:37 -0000	1.513
+++ includes/form.inc	6 Dec 2010 10:14:05 -0000
@@ -3288,6 +3288,12 @@ function form_process_machine_name($elem
     return $element;
   }
 
+  // If the source element comes after the machine name element in the form
+  // structure, then it may not have an #id yet.
+  // @see form_builder()
+  if (!isset($source['#id'])) {
+    $source['#id'] = drupal_html_id('edit-' . implode('-', $source['#parents']));
+  }
   // Append a field suffix to the source form element, which will contain
   // the live preview of the machine name.
   $suffix_id = $source['#id'] . '-machine-name-suffix';
