Hi i am having issues trying to create a multipage form. I have read lots of info on this especially this
yii-multi-page-form-wizard-best-practice on stackoverflow
But I am having issues with validation. When trying to move from step one of the form, validation fails because its trying to validate fields that are not in that step.
I then removed validation from each step and instead validated on save. But after doing this i notices none of the data was being stored. So when the validation fails and goes back to the first page the form is empty.
Could anyone see what i am doing wrong?
My controller code is below:
public function actionCreate()
{
$model=new Accounts;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['accountsStep2']))
{
$this->setPageState('step1',$_POST['Accounts']);
$model=new Accounts('step1');
$model->attributes = $_POST['Accounts'];
$this->render('create',array(
'model'=>$model,
'formLevel' => '2',
));
}
elseif(isset($_POST['AccountsFinish']))
{
$model->attributes=$_POST['Accounts'];
if($model->save()) {
$this->redirect(array('view','id'=>$model->accountID));
} else {
$this->render('create',array(
'model'=>$model,
'formLevel' => '1',
));
}
} else {
$this->render('create',array(
'model'=>$model,
'formLevel' => '1',
));
}
}