I'm making a custom validation in a form I'm making but my error message is always delayed by one page refresh.
$form['submit']['#validate'][] = 'asap_sollicitation_form_validate';
function asap_sollicitation_form_validate($form, &$form_state)
{
if(strlen($form_state['values']['pass']) < 6){
form_set_error('pass', t('Must be longer than 6'));
}
}
It successfully marks the field in red but the message is delayed. If I use only drupal_set_messsage
without the form_set_error I do get a message displayed in time.
I render my form in a node template:
$arr = drupal_get_form('asap_sollicitation_form');
print drupal_render($arr);
How can I get my message to display after form submit?
$_SESSION['message']
is being set on the next page load.drupal_set_message()
just sets a$_SESSION['message'][]
.'#title'
fields in your form array, if not can you add that and try. Drupal is using that field to figure out I think.