By fgasking on
Hi there,
I need to create a module that when enableed will create a form accessed from a particular alias I can link to, and which consists of 2-3 steps and various pathway routes based on choices made. The form pages will only be available to a particular set of roles.
Does anyone know if there are any good tutorials that go through using the form.api to do this kind of thing?
I'm using Drupal 6 btw.
Many thanks,
Frank
Comments
Did you find an answer? I am
Did you find an answer? I am looking for the same thing.
Did you try the Multipage module?
http://drupal.org/project/multipage
There seems to be a solution
There seems to be a solution of sorts in the "Pro Drupal Development" book, but i'm yet to test this out. It means a bit of a rethink of how I was planning to build my step by step, but it might work.
I'll report back if I have any joy with it :)
Thanks for the hint. Yes,
Thanks for the hint. Yes, the section in the second edition of "Pro Drupal Development" was definitely useful.
It did not deal with validation though.
If you add validation, and if there are validation errors, then you explicitly have to decrement the step saved under
$form_state['storage']['step']. You will probably have to callform_get_errorsand count if there are errors, because there could be errors like required fields which are not set explicitly by you.Also, now you have to explicitly set
#default_valuefor each form element to be$form_state['values'][...]so the form reloads properly when there are validation errors. If you don't do that then all the values are lost and the user has to fill in everything.I've recently used the
I've recently used the example in my own code, with modification and yes... for the validation part you have to keep track of the step and decrement it to ensure that the validation error doesn't appear on the next page.
It requires a bit of fiddling around to get how you want, but its working at the moment, so i'm happy :)