diff --git a/conditional_fields.module b/conditional_fields.module
index 9a751dc..d98a867 100755
--- a/conditional_fields.module
+++ b/conditional_fields.module
@@ -637,10 +637,15 @@ function conditional_fields_node_form(&$form, $form_state) {
  * - Apply orphaned fields settings if applicable
  */
 function conditional_fields_node_after_build($form, &$form_state) {
-  // Avoid running twice when the form is rebuilt with AHAH
-  if (!empty($form_state['clicked_button']['#ahah'])) {
+  // Avoid running twice when the form is rebuilt with AHAH.
+  // For some reason, $form_state['clicked_button']['#ahah'] is populated
+  // even if the user submits the form pressing the enter key, so we can't
+  // rely on it.
+  static $run;
+  if (!empty($run[$form['#build_id']])) {
     return $form;
   }
+  $run[$form['#build_id']] = TRUE;
 
   $type_name = $form['type']['#value'];
 
