How to separate forms into 3 steps?

Using the blog sample ContactForm, I need to create a User Registration form where the fields are broken into a few pages, like Next Next Next Done…

Do I create in the model RegisterForm, RegisterForm_1, RegisterForm_2, RegisterForm_3 and the views/actions register, registerStep_2, registerStep_3, and so on?

Please help me with some examples on how to do this.

Thank you…

public function actionRegister()


  $model=new RegisterForm;






      $headers="From: {$model->email}\r\nReply-To: {$model->email}";


      Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');




  $this->render('registerStep_2',array('model'=>$model)); //<--- like this?


In my case i’m using AR model directly.

    $user = $this->app->user;

    $step = $this->request->getParam('step');

    $model = UserForm::model()->findByAttributes(array('id'=>$user->id));

    if ($model === null)


      $model = new UserForm();

      $model->id = $user->id;


    $step = $step ? $step : 1;


    if ($this->request->getIsPostRequest())


      $model->attributes = $this->request->getParam('UserForm');

      if ($model->validate() && $model->save())


         $this->redirect(array('profile/first', 'step'=>$step+1));



    // parts of form included inside 'first' with renderPartial

    $this->render('first', array('model'=>$model, 'step'=>$step));


And model validation for each step with ‘on’ => ‘step1’, ‘on’ => ‘step2’ etc

Don’t know if this is an option for you, but you could use one single html form to collect the data from users and use jquery/CSS to hide parts of it. So the click on “next” would only toggle what parts of the form are currently visible to the user. This way, you can implement a wizard without having to split forms and/or models.

As an example, try this one (don’t know it, only did a quick search on google to show what I mean).