I'm building a custom multi step form based on this tutorial:
http://pingv.com/blog/ben-jeavons/2009/multi-step-forms-drupal-6-using-v...

I added "back" buttons to each stage so it's possible to go back to earlier stages. My only problem is that when there are required fields clicking the "back" button triggers the internal validation and i'm getting an error message staying that fields X,Y,Z.. must be filled. Since drupal treats both "button" and "submit" element types as "submit" i can't find any way to do it. I know that i can lose the required elements and write my own validation function that check for fields X,Y,Z etc...

Is there any way to temporarily bypass the internal form validator?

or better yet has anyone come with hack that enables using simple buttons with drupal forms??

thanks!

Comments

Anonymous’s picture

Subscribing
I would like to know to!

-----------------------------------------
Joep
CompuBase, Drupal, websites and webdesign

sirkitree’s picture

Take a look at the development code for Activity2 (DRUPAL-6--2). You'll find some stuff I was able to do with this in the activity.admin.inc

Love to see what you come up with!

~Jerad


~Professional: Lullabot
~Personal: jeradbitner.com

Anonymous’s picture

Thanks Jerad for the quick response.
I downloaded activity-6.x-1.2.tar.gz and activity-6.x-2.x-dev.tar.gz but I cant find the mentioned activity.admin.inc.

Cheers, Joep

Anonymous’s picture

The internal validater is called before the form validate or submit so there is no clean way to do it.
I ended up with an ugly one:

function form_foo_validate ($form, &$form_state) {
  if ($form_state['clicked_button']['#id'] == 'edit-form-step-2-back-submit') {
    unset($_SESSION['messages']['error']);
    return;
  }
}

from d6.14 the code above will not do the trick anymore:

function form_foo_validate ($form, &$form_state) {
  if ($form_state['clicked_button']['#id'] == 'edit-form-step-2-back-submit') {
    unset($_SESSION['messages']['error']);
    $form_state['submitted'] = true;
    form_set_error(null, '', true);
    return;
  }
}