2

so evidently if I turn a form into a multistep form:

  if(!isset($form_state['storage']['step']))
    $form_state['storage']['step'] = 1;

and do form_set_error() in validate

when the validation error appears, the values that I previously put in would disappear.....

so If I enter a value into a textbox in a multistep form then hit continue then validation error appears, the textbox will now be empty instead of being filled with my previously entered values as it would happen normally

is there a way to prevent this from happening without manually reentering the default values for every form element?

fyi I'm using drupal 6

  • The "examples" module has a multistep form example. Maybe that would be of some help. – Varshith Apr 24 '12 at 9:23
1

I was bitten by a similar case in a multistep form scenario, though in my case it was use of the "Previous" button that didn't preserve user entered values.

Initially I was under the impression that D7's form_builder() would automatically merge user data in $form_state['values'] back into the '#value' property of the form elements on previous step's subform, but this never happened!

After reading carefully through examples module, form_example/form_example_wizard.inc, I realized that I had to use:

'#default_value' => !empty($form_state['values']['my_elem']) ? $form_state['values']['my_elem'] : '',

on all form elements that I wanted to "remember" their user input!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.