Multi Steps Form Wizard

I have these models

PatientInfo

Controller




    public function actionCreate()

    {

        $model = new PatientInfo();


        if ($model->load(Yii::$app->request->post()) && $model->save()) {

            return $this->redirect(['view', 'id' => $model->patient_id]);

        } else {

            return $this->render('create', [

                'model' => $model,

            ]);

        }

    }



Model




    public function attributeLabels()

    {

        return [

            'patient_id' => 'Patient ID',

            'email' => 'Email',

            'mobile_line' => 'Mobile Line',

            'other_lines' => 'Other Lines',

            'first_name' => 'First Name',

            'middle_name' => 'Middle Name',

            'last_name' => 'Last Name',


        ];

    }



PatientDependant

Model




    public function attributeLabels()

    {

        return [

            'dependant_id' => 'Dependant ID',

            'patient_id' => 'Patient ID',

            'first_name' => 'First Name',

            'middle_name' => 'Middle Name',

            'last_name' => 'Last Name',

        ];

    }



PatientMedicalInfo

Model




    public function attributeLabels()

    {

        return [

            'patient_medical_id' => 'Patient Medical ID',

            'patient_id' => 'Patient ID',

            'pref_med_cond' => 'Pref Med Cond',

            'allergies' => 'Allergies',

            'prior_surgery' => 'Prior Surgery',

            'medications' => 'Medications',

        ];

    }



  1. It will first load the info on PatientInfo, When I click on Next, it saves and move to PatientDependant

  2. On patientDependant, When I click on Next, it saves and move to PatientMedicalInfo. But when I click Previous, it moves back to PatientInfo.

  3. On patientMedicalInfo, When I click on Finish, it saves and display everything on a view. But when I click Previous, it moves back to PatientDependant.

Please help me out.

Thanks