Experimental project

This is a sandbox project, which contains experimental code for developer use only.

How it works

FormToWizard provide a fast and simple way to turn regular drupal form into a multistep wizard. It divides form by steps based on <fieldset> elements. Legend is used to show Step name.

You can check test form after the module activation at: /admin/config/user-interface/form-to-wizard

Usage examples

drupal_get_wizard_form($form_id, $submit_button_element);
drupal_get_wizard_form('mymodule_example_form', 'submit');
function mymodule_example_form($form, &$form_state) {
  $form = array(
    // Regular drupal form definition
    'submit' => array(
      '#type' => 'submit',
      '#value' => 'Submit'
    )
  );
  
  return $form;
}

// before:
// drupal_get_form('mymodule_example_form');
// after:
drupal_get_wizard_form('mymodule_example_form', 'submit');

To be developed: Alternative usage (Not releaased yet!):

function mymodule_example_form($form, &$form_state) {
  $form = array(
    // Regular drupal form definition
  );
  
  $form['#type'] = 'wizard';
  return $form;
}

drupal_get_form('mymodule_example_form');

To be developed: Configuration options

FormToWizard has several optional configuration options accessible on the module configuration page to make your life better:

Forward button:
    caption: text caption
    callback: callback function triggered on click
    class: one or several css classes
  
Backward button:
    caption: text caption
    callback: callback function triggered on click
    class: one or several css classes
  
Submit button:
      id: Submit button id
      callback: callback function triggered on click
  
Step:
      caption: step caption text

Project information

  • Created by lifecoderua on , updated