Pedro Posada | Drupal 6 Multistep Form Oddities - $form_state empty

Drupal 6 Multistep Form Oddities - $form_state empty

Posted on March 22, 2010 - 10:47am
<< 8 of 54 >>

Interesting link about drupal multi-step forms loading twice problem.

I created a form using drupal's form api or FAPI. The form would load twice on the first submission. The first time the $form_state['storage'] goes empty and the second time is populated. I wanted to use $form_state to store some values and do some checks.

The problem starts when you want to use drupals validation mechanism, when you set rules in the _form_validate function, then the whole form gets loaded twice but the $form_state won't work because its empty and then populated, so any code you have in your form definition function will run twice.

The following link explains how to use $_POST to avoid your code to run twice.

Drupal 6 Multistep Form Oddities - $form_state empty

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.