Best practices for complex questionnaires

I’m about to develop an application that deals with complex questionnaires. The user starts out with one form and depending on the answers is then directed to a second form A or a second form B. The forms might also vary slightly in content, depending on previous answers. In total the user might be presented with 8-10 forms.

Are there best practices for dealing with this kind of challenge?

Save each step separately?

In my experience, first i create only one model called Wizardxxx. It contains all the field of each step and also a field called "step". I can also use other model rules validation as you can see in this example, the field email > unique

class Wizarduserregister extends Model


    public  $step;

    public  $email;

    public  $password;

    public  $name;

    public  $surname;

    public  $password;

    public function rules()


        return [

            [['email'], 'string', 'max' => 255],

            [['email'], 'unique', 'targetClass' => '\app\models\User', 'targetAttribute' => 'email'],

            [['email'], 'filter', 'filter' => 'trim'],

            [['email'], 'email'],

            [['email'], 'required'],

            [['password'], 'string', 'min' => 3],

            [['password'], 'filter', 'filter' => 'trim'],

            [['password'], 'required'],

            [['step'], 'integer'],

            [['name','surname','note'], 'string'],




After that the controller contain a main action where i check the Step field and do something. For example:

    public function actionRegisterwiz(){

        $wiz = new Wizarduserregister();


        if (! ($wiz->step > 0)) {$wiz->step = 1;} //entry step

        switch ($wiz->step) {

            case 1:

                // do step 1 actions

                // ...

                $wiz->step = 2;

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

                    'model' => $wiz,



            case 2:

                // do step 2 actions

                // ...

                $wiz->step = xxx;

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

                    'model' => $wiz,


                break;        }


I hope it can help you