multistep_form_framework
This module provides a framework for creating multistep forms in Drupal 8.x. While similar notable projects exist on Drupal.org, the goal of this project is to simplify the process of creating multistep forms for developers while maximizing flexibility in configuration. The module doesn't provide any kind of UI, it's created only for developers.
Module provides Yaml plugin system like *links.action.yml, where you can specify each step, and also replace/extend plugin itself. The benefits of such approach are:
- One place to configure everything
- You can specify whatever namespace you want for steps, which is good if you have a few multistep forms in one module because you will be able to sort them logically
Usage
1. Create your form, and extend it with \Drupal\multistep_form_framework\Form\MultistepForm class. The only required thing is to set form id ::getFormId, which later will be used to identify plugin.
2. Add MODULE_NAME.multistep_wizard.yml file to your module.
Example:
your_form_id_here:
steps:
-
id: greetings
class: \Drupal\multistep_form_framework_examples\Form\BuyBookStep\Greetings
-
id: book_attributes
class: \Drupal\multistep_form_framework_examples\Form\BuyBookStep\BookAttributes
-
id: description
class: \Drupal\multistep_form_framework_examples\Form\BuyBookStep\Description
-
id: graz
class: \Drupal\multistep_form_framework_examples\Form\BuyBookStep\Congratulation
How does this module differ from other community projects and examples?
The Webform allows building multi-step, wizard-style forms and provides a decent UI. If you don't need to deal with non-trivial tasks like multiple entities generation or some insane widgets then I encourage you to use Webform instead of this module.
Multi Step Form Example provides a intuitive demonstration of creating multistep forms. This framework differs in that it eliminates the need for a StepManager class and allows for iterations to jump arbitrarily to any step, even based upon custom logic of the previous submit.
πΊπ¦
This module is maintained by Ukrainian developers.Please consider supporting Ukraine in a fight for their freedom and safety of Europe.