Update $form based on $form_state Shouldn't the form generating function get executed every time the form is rendered? Because I need to update some field suffixes based on the $form_state values and I don't know how to do this.

I have something like this:

function xxxx_some_form($form, &amp;$form_state){
  $form["some_field"] = array(
    "#type" =&gt; "textfield",
    "#required" =&gt; true,
    // bla bla bla
  );
  drupal_set_message("whatever");
  $form["actions"]["do_action"] = array(
    "#type" =&gt; "submit",
    "#value" =&gt; t("Do action"),
  );
  return $form;
}


When I submit the form, the validation messages are displayed ( Eg: X field is required ) but the message from drupal_set_message("whatever") is not displayed.

Also, no other logic is executed there.
When a form has a validation error, the form is rebuilt from cache, meaning that the form function isn't invoked.

I could move the drupal_set_message call over to a #process or #preprocess function on the form itself or on one of the methods. These should be called again.

If the form is displayed with hook_menu you could also make a callback function which calls drupal_set_message and then fetches the form. There are a lot of ways to get around this.