Wizard Behavoir is an extension that simplifies the handling of multi-step forms.
Features ¶
- Data persistence
- Plot-Branching Navigation (PBN)
- Next/Previous or Forward Only navigation
- Optional step timeout
- Invalid step handling
- All steps submit to the same URL (contoller/action); this greatly simplifies routes
- Save and recover wizards between sessions
- Utility methods for use in views to assist navigation
Requirements ¶
Developed using Yii 1.1.6. Should work with all versions
Usage ¶
The Very Brief Version ¶
- Set up the steps array in the Wizard Behavior configuration
- Attach Wizard Behavior to a controller
- Call WizardBehavior's process() method from the desired action
- Handle the events that WizardBehavior raises
The Long Version ¶
Please see the the manual for full details on using Wizard Behavior - it also fully documents the API and contains example code, and/or download the demo application.
Plot-Branching Navigation (PBN) ¶
PBN allows a wizard to change the path depending on a response from a user. A simple example: you ask the user their gender; you can then take a different path through the wizard presenting gender specific forms depending on their response.
Resources ¶
Credits ¶
Wizard Behavior was inspired by the CakePHP Wizard Component: http://github.com/jaredhoyt
Total 20 comments
I've found a copy of the manual at
http://www.scribd.com/doc/120297741/Yii-Multi-Page-Form-Wizard-Behavior-Manual
to julianm. Check the link I provided below. It's not pdf but you can save the html page and use it as it is.
This seems to be a great extension, but unfortunately the links are not working and wizard_behavior_manual.pdf can't be found. Is there any way to re-upload it?
Here is the link with docs for wizard behavior if anyone needs it.
If you try to run the demo code, you may encounter an error: "Object not found". It happens when you run a wizard all the way to the end. The completed.php view tries to load the models that it finds in the event steps. But the event step names all start with a lower case character, while the models have an uppercase.
2 possible solutions:
1. In beforeAction of DemoController.php change the event step names to match the model names exactly, or
2. In the view completed.php replace
with:
On our dev server it's fine but on the live server in place of the form I get Object id #31. Anybody have any ideas?
The demo isnt working at the moment?
Other than editing the path to framework folder is there any other configuration. The zipped demo does not run. Gives Object not found error
Thanks for the great extension.
If you are going back steps and pruning everything in front of you, or if you implement looping over a single step with no steps in front of it, you are going to want to make a change to isValidStep($step) as follows:
Reasoning: The next expected step is the next step which does not have data. If there are no more steps, and the current step already has data but is being resent (due to going back or looping), the resend would fail. So we say if no further expected step, step is valid as long as it is within range of total steps.
This is really just a tiny detail but could be annoying if one do not pay attention, in the demo: $config['class']='application.components.WizardBehavior';
in the manual: it says the common place to put the file is in the extentionfolder..
I noticed my mistake early so no time wasted.
I was working from your demo Registration wizard, and everything worked fine on our development server. When loading the app to our production server we get 'Object id #32' displayed where the Login Form should be displayed. Everything else displays fine.
Here is the generated page snippet:
On Yii 1.1.3 actions declaration in controller don't allow default arguments, and for some reason WizardBehavior component can't identity the current step value and enters an infinite loop:
Original from the demo:
Edit to make that work:
Maybe it can be fixed from inside the component in a future update.
Hope it helps someone!
Hi,
I just wanted to say I have found a broken link on the demo page: http://wizard-behavior.pbm-webdev.co.uk/
Download The Wizard Behavior and/or the code for this demo: http://www.yiiframework.com/extension/wizard-behaviour/ <- wrong one http://www.yiiframework.com/extension/wizard-behavior/ <- good one
That's it, now I am going to test it because it's just what I need for my forms!! thanks! :)
Hi I got the whole wizard going it's great , but I have an interface request where I have to submit the surveys with a link (javascript submit) but this strangely seems to block the process of going to nextStep in some way I don't really understand ? if by any chance someone got it working , I'd love a use case or a sample Cheers
Have you tried putting the step you want to repeat inside a branch, then repeatedly selecting it using the branch() method?
I should add - I don't know how many iterations I will need beforehand, so I can't just add more of the same steps to WizardBehaviour::steps.
So my last step in the config is 'getThingForm' and I only have one of those, but need to go back to it programmatically based on an interation count entered in a previous step by the user.
Cheers
Russell
Thanks Yeti
Good idea about saving into the session using an iteration value. I'll give it a try.
I spent most of this afternoon trying to figure out how to make processStep go back to the same step.
I tried setting WizardBehaviour::handled = false. I tried using $this->process('StepName'). I tried making WizardBehaviour::previousStep() public and using that. I tried $this->redirect()
All failed. Now my head hurts. :-)
Any pointers to how I make it repeat the step?
Thanks Russell
Currently the wizard saves data using the step name as the key, so reusing a step name will just overwrite the data for that step.
The following might be worth trying: (In WizardBehavior)
You would need to track which iteration you are on in the process step handler.
When you retrieve the data at the end of the wizard, repeated steps will have the repetitions as an array.
Let me know if it works - if so I'll add it in to the released version.
I also need repeating steps several times (i need cycling), but in the following way:
1) Step1 2) Step2 3) Step3 4) Ste[4 -> finish or go to step2 again I need repeating step2-step4 till user decides to finish.
Hi
I need to repeat step several times.
Here's my example:
I've tried this in my processStep handler:
Any ideas how I can make the same step run more than once?
thanks in advance
Russell
Leave a comment
Please login to leave your comment.