Index: includes/ajax.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/ajax.inc,v retrieving revision 1.7 diff -u -p -r1.7 ajax.inc --- includes/ajax.inc 27 Aug 2009 04:40:12 -0000 1.7 +++ includes/ajax.inc 1 Sep 2009 14:44:24 -0000 @@ -214,14 +214,18 @@ function ajax_form_callback() { if (function_exists($callback)) { $html = $callback($form, $form_state); - // If the returned value is a string, assume it is HTML and create - // a command object to return automatically. + // If the returned value is a string, assume it is HTML, add the status + // messages, and create a command object to return automatically. We want + // the status messages inside the new wrapper, so that they get replaced + // on subsequent AJAX calls for the same wrapper. if (is_string($html)) { - $commands = array(); $commands[] = ajax_command_replace(NULL, $html); + $commands[] = ajax_command_prepend(NULL, theme('status_messages')); } // Otherwise, $html is supposed to be an array of commands, suitable for - // Drupal.ajax, so we pass it on as is. + // Drupal.ajax, so we pass it on as is. In this situation, the callback is + // doing something fancy, so let it decide how to handle status messages + // without second guessing it. else { $commands = $html; } Index: modules/field/field.form.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field/field.form.inc,v retrieving revision 1.23 diff -u -p -r1.23 field.form.inc --- modules/field/field.form.inc 27 Aug 2009 04:40:12 -0000 1.23 +++ modules/field/field.form.inc 1 Sep 2009 14:44:28 -0000 @@ -362,9 +362,13 @@ function field_add_more_js($form, $form_ $field_form[$langcode][$delta]['#prefix'] = '
' . (isset($field_form[$langcode][$delta]['#prefix']) ? $field_form[$langcode][$delta]['#prefix'] : ''); $field_form[$langcode][$delta]['#suffix'] = (isset($field_form[$langcode][$delta]['#suffix']) ? $field_form[$langcode][$delta]['#suffix'] : '') . '
'; - $output = theme('status_messages') . drupal_render($field_form); - + // Everything below this comment could be replaced with + // return drupal_render($field_form); + // But then we wouldn't have an example in core of an AJAX callback that + // returns an array of commands. + $output = drupal_render($field_form); $commands = array(); $commands[] = ajax_command_replace(NULL, $output); - ajax_render($commands); + $commands[] = ajax_command_prepend(NULL, theme('status_messages')); + return $commands; } Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.311 diff -u -p -r1.311 poll.module --- modules/poll/poll.module 29 Aug 2009 05:46:03 -0000 1.311 +++ modules/poll/poll.module 1 Sep 2009 14:44:30 -0000 @@ -382,7 +382,7 @@ function _poll_choice_form($key, $chid = function poll_choice_js($form, $form_state) { $choice_form = $form['choice_wrapper']['choice']; - return theme('status_messages') . drupal_render($choice_form); + return drupal_render($choice_form); } /**