Wizard Forms


I have been programming with Yii for a couple of weeks, have had success customizing for my look and feel, and also have customized the login form to match my requirements.

Now I’m about to do the User Registration part.

I’m new to MVC and Yii, so sometimes I get lost.

I would like to have 3 views, like three wizard pages, for different parts of the registration, like username, password, then personal information, then hobbies, each one in a new wizard page. I will have a user table and a userProfile table. This should go each to two models, shouldn’t it?

So, I don’t know how to split one view to handle this scenario.

Any opinion is valid! I can change the structure if needed and if it’s reasonable.

Thank you!

For DB tables i use an AR model and for forms i use a CForm Model. I would go a head and use two AR tables for the two tables and a single RegistrationForm that handles three actions(?) as you described for the three different registration processes. You could use CJuiTabs to do the three stages split.

I want to do as well a lets say 4-5 stage form. Can someone give an example how to do this with CActiveForm?

I want to share my approach to create a multi-page form. Please tell me if its so ok or i am complicating it.

I have in my Controller the function actionCreate:



				if ($_POST[1]) {

					$_SESSION['form'][2] = $_POST['form'];

					if ($_SESSION['form'][1]) {

						foreach ($_SESSION['form'][1] as $key=>$value){





					$_SESSION['form'][1] = $_POST['form'];

				} // endif


In the _form.php View i have an CActiveForm widget with Buttons named 1 and 2, so when i am on the first page i click the button 2 to display the second page and save the posted variables in my session.

When i want to go back to the first page i click on the Back-Button -> 1 and the values from the session are populated back to my form with the foreach loop.

Thank you in advance for your ideas on this.

Why not to use a bit of javascript?

You can write all the form in one html page, and create some <div> in wich to put your wizard’s page.

The button next-back are simple javascript button that plays a bit with visibility of panels.

Using this apporoach you can leave the action in the controller as it is, because you have at any post all the input (and so you don’t have to dirty on $_SESSION), and is even a bit (but just a bit) more efficient, because you avoid some posts.

If the wizard is "static" (if the nexts pages are not depending from data inserted in the previous), that can be a solution.

Wizard behaviour in attachment (not perfect, but at least something)



	 * @return array


	public function behaviors(){

		return array_merge(parent::behaviors(),array(














Thank you very much

. I was looking for something similar. This kind of form is not mentioned neither in the forum nor in the tutorials.

I think that would do the trick B)

I am new to the yii framework but eager to learn new things ;D

An jscript div-hide is not working for me, because i want forms to be usable with and without js enabled . Thank you anyway zaccaria

I am new to php and yii. Can someone provide an example / steps on how to use ext.behaviors.CWizardBehavior?


another wizardBehavior Extention wizardBehaviorExt i don’t know the differences of two :)