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;
if(isset($_POST['RegisterForm']))
{
$model->attributes=$_POST['RegisterForm'];
if($model->validate())
{
$headers="From: {$model->email}\r\nReply-To: {$model->email}";
mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('registerStep_2',array('model'=>$model)); //<--- like this?
}
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).