Wizards take the user through a multi-screen sequence of forms, collecting data at each step. Collected data is stored in hidden fields in each screen. The submission of the aggregate form data does not occur until the final screen is submitted. This allows wizard forms to have branching logic, or inputs that vary in character, depending on the inputs provided on previous screens.
To create a wizard:
my $wiz = new ExSite::Wizard(title=
``My Wizard'',action=>``mywiz.cgi'');>
$wiz-
add_step(``First'',\&create_step_1,\&do_step_1);>
$wiz-
add_step(``Second'',\&create_step_2,\&do_step_2);>
mywiz.cgi
is your wizard script that processes each screen;
&create_step_X
is the routine that composes and returns a form for step X.
It should return the HTML for the form in a string. The Wizard automatically
outputs the form tags, submit buttons, and data from previous steps (as
hidden fields), so you only need to output the new input fields for this
screen.
&do_step_X
is the routine that processes the form from each step. It
should return an array of error messages (such as input validation failures,
or other problems). If this array has no entries, the form input is
accepted, and the wizard automatically proceeds to the next step.
The last &do_step_X
routine in the wizard is responsible for doing
final processing of the collected data, ie. handling the final submit
of the aggregate wizard inputs. It also returns an array of error strings
if the final collection of data cannot be processed; if the error array
is empty, the wizard is assumed to have completed.
If the last &do_step_X
routine is not specified, then ExSite will
run the last &create_step_X
routine, and not display any wizard buttons
to ``do'' this step. This is useful if you need to provide final instructions
on the last Wizard screen.