Yii Framework Forum: Double Render In Single Window - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Double Render In Single Window

#1 User is offline   Aashis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 18-March 12

Posted 26 April 2013 - 11:28 PM

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???
0

#2 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 148
  • Joined: 07-March 12

Posted 26 April 2013 - 11:48 PM

View PostAashis, on 26 April 2013 - 11:28 PM, said:

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));
           }

0

#3 User is offline   artificial 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 96
  • Joined: 11-December 10
  • Location:Sydney, Australia

Posted 27 April 2013 - 12:04 AM

Throw a return; after your first render.
Alex Berriman
www.fishvision.com
0

#4 User is offline   Aashis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 18-March 12

Posted 27 April 2013 - 08:32 PM

View PostReza m, on 26 April 2013 - 11:48 PM, said:

you can solve it several ways for example



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

#5 User is offline   Aashis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 18-March 12

Posted 27 April 2013 - 08:34 PM

View PostArtificial, on 27 April 2013 - 12:04 AM, said:

Throw a return; after your first render.


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

#6 User is offline   artificial 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 96
  • Joined: 11-December 10
  • Location:Sydney, Australia

Posted 27 April 2013 - 09:21 PM

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));
           }

Alex Berriman
www.fishvision.com
0

#7 User is offline   Aashis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 18-March 12

Posted 28 April 2013 - 10:29 AM

View PostArtificial, on 27 April 2013 - 09:21 PM, said:

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 :-)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users