form validation messages are not rendered immediately I have a form, with multiple (ajax) components. I have added a simple button in the middle of this form, to validate custom fields.

$form['fieldset_2']['forward'] = array(  
  '#type' =&gt; 'button',
  '#value' =&gt; t('Forward'),
  '#name' =&gt; 'btn_forward',
);


As expected, button call validation function in which I check if all values are correct. 


The validation messages are not rendered immediately. I have to refresh page to get the error messages. The button doesn't use ajax. 
I have a field type radios and form_set_error doesn't color the element with red or something.
The problem is that Drupal has already finished setting messages for the current request when it gets to processing your form. To get things working properly call drupal_get_form in template_preprocess_page:

function myThemeOrModulename_preprocess_page(&amp;$variables) {
  // For node templates.
  // $variables['node']-&gt;my_form = drupal_get_form('form_name');
  // For page templates.
  $variables['my_form'] = drupal_get_form('form_name');
}


Then render the form in your template file:

&lt;?php print render($my_form); ?&gt;


There was another issue for which I don't know the cause of currently, but adding $variables['messages'] = theme('status_messages'); (see theme_status_messages) inside the same preprocess_page function solved it.