The template includes a wizard form styling:
To use the wizard with the included plugin, use this style of markup (see demo file wizard.html for the full markup):
<!-- Form element with wizard class --> <form method="post" action="" class="block margin-bottom wizard same-height"> <!-- Block style is optional, you can use any layout --> <h3 class="block-title">Wizard</h3> <!-- Each form step should be wrapped in a fieldset --> <fieldset class="wizard-fieldset fields-list"> <!-- The legend is used to retrieve step's title - if omitted or empty, the default title is used (see defaults below) --> <legend class="legend">About you</legend> <!-- Example input markup - optional, use any element within the fieldsets --> <div class="field-block button-height"> <label for="first_name" class="label"><b>First name</b></label> <input type="text" name="first_name" id="first_name" value="" class="input"> </div> ... </fieldset> <!-- Add as many fieldsets as required --> </form>
The plugin will handle building the indicator and navigation in steps.
By default, the plugin will add an extra block at the end of each fieldset, to embed controls. If you want to have a specific layout for some steps, build your own navigation block and add the class wizard-controls to it, the plugin will automatically use it.
To use the wizard full-page style, see the demo file wizard.html for complete markup and centering code.
The wizard can handle form validation for each step. Just set the form validation plugin classes (see related section) and init form validation, the wizard will take care of validating each step by itself:
$('.wizard').validationEngine();
If you add or remove a fieldset to the form, just call the method wizard() on it, it will rebuild the progress indicator and include the new steps in the process. Just note that if you add steps before the current one, this may lead to some form validation bugs.
$('.wizard').wizard();
The plugin will also send some events to help you hook your own functions in the wizard:
$('.wizard').on('wizardchange', function() { // Called everytime the active step changes }); $('.wizard fieldset').on('wizardenter', function() { // Called everytime a step (fieldset) becomes the active one }); $('.wizard fieldset').on('wizardleave', function() { // Called everytime a step (fieldset) stops being the active one });
If you want to use the wizard style above, but without the plugin (for instance, is you process steps server-side), use the same markup as above, replace the class wizard by wizard-enabled on the form (fieldsets have a special style when JS is disabled, this class removes it) and add the progress indicator below:
<ul class="wizard-steps"> <li class="completed"><span class="wizard-step">1</span> Completed</li> <li class="active"><span class="wizard-step">2</span> Active</li> <li><span class="wizard-step">3</span> Locked</li> </ul>
Convert a form into a wizard (to be called on a fieldset or on any element inside it)
@var object options - optional (see defaults for a complete list)
Show a specific step of a wizard (to be called on a fieldset or on any element inside it)
@param boolean force true to force display even if step is not unlocked yet (optional, default: false)
Show the previous step of a wizard (to be called on the form)
@param boolean force true to force display even if step is not unlocked yet (optional, default: false)
Show the next step of a wizard (to be called on the form)
@param boolean force true to force display even if step is not unlocked yet (optional, default: false)
Mark a step as completed (to be called on a fieldset or on any element inside it)
Set a step as current (to be called on a fieldset or on any element inside it)