Double Render In Single Window

Let me try to explain:


public function actionOne()

          {

            //assume $model is declared

            if(isset($_POST['Table1']))

            {

                //save the data and then redirect to another action

                

                 $this->actionTwo();

            }

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

           }




     public function actionTwo()

          {

             //assume $m1 is declared

             //do something and render

            $this->render('One',array('m1'=>$m1));

           }




If i write like this than, what happens is:- in my browser two views are rendered at the same time.And I don’t want that to happen. So how to do???

you can solve it several ways for example




public function actionOne()

          {

            //assume $model is declared

            if(isset($_POST['Table1']))

            {

                //save the data and then redirect to another action

                

                 $this->actionTwo();

            }

            else

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

           }



but I think this call of another action in an action is not nice, what is your usecase scenario and why you don’t use redirect?




public function actionOne()

          {

            //assume $model is declared

            if(isset($_POST['Table1']))

            {

                //save the data and then redirect to another action

                

                 $this->redirect(array('actionTwo'));

            }

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

           }



Throw a return; after your first render.

Actually i wanted to see the other options to solve… And u just showed me… Thanks for help…

I did not get what u r saying. just explain in the form of example please. U can copy the above example any modify


public function actionOne()

          {

            //assume $model is declared

            if(isset($_POST['Table1']))

            {

                //save the data and then redirect to another action

                

                 $this->actionTwo();

                 return;

            }

            else

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

           }

Yes, i get it now, thank u so much :slight_smile: