Yii Framework Forum: Redirect Problem - Yii Framework Forum

Jump to content

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

Redirect Problem Rate Topic: -----

#1 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 145
  • Joined: 22-September 12

Posted 12 December 2012 - 02:16 PM

I have a controller that calls an insert to a model then redirects to a view (CGridView)
Works great.

I have another function that is essentially identical but does not redirect. The function performs an update of the model gets called using updateAll($criteria) and works fine, but the redirect never happens. If I comment out the update, the redirect does occur.

Here is my controller code.

    public function actionCreateReviewlist($id) {     

	PartnerSite::model()->createReviewList($id);
		
	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);

	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
	
    }

    public function actionReviewlist($id) {
       
	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);
	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
    }

    public function actionReleaseNew($id) {     

	PartnerSite::model()->releaseNew($id);	

	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);

	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
//	$this->redirect(array('blacklist','id'=>$id));
    }


Any ideas? Thanks in Advance.
0

#2 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 145
  • Joined: 22-September 12

Posted 12 December 2012 - 02:47 PM

View PostAustinGeek, on 12 December 2012 - 02:16 PM, said:

I have a controller that calls an insert to a model then redirects to a view (CGridView)
Works great.

I have another function that is essentially identical but does not redirect. The function performs an update of the model gets called using updateAll($criteria) and works fine, but the redirect never happens. If I comment out the update, the redirect does occur.

Here is my controller code.

    public function actionCreateReviewlist($id) {     

	PartnerSite::model()->createReviewList($id);
		
	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);

	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
	
    }

    public function actionReviewlist($id) {
       
	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);
	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
    }

    public function actionReleaseNew($id) {     

	PartnerSite::model()->releaseNew($id);	

	$model = new PartnerSite('search');
	$model->unsetAttributes();
	if (isset($_GET['PartnerSite']))
                $model->setAttributes($_GET['PartnerSite']);

	$this->render('reviewlist', array(
                'model' => $model, 'partner_id' => $id,
        ));
//	$this->redirect(array('blacklist','id'=>$id));
    }


Any ideas? Thanks in Advance.



I think it must be some error condition coming out of the updateAll() method but it seems to work fine. The fact the redirect
does not occur makes me think it is not returning.
0

#3 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 145
  • Joined: 22-September 12

Posted 12 December 2012 - 03:00 PM

View PostAustinGeek, on 12 December 2012 - 02:47 PM, said:

I think it must be some error condition coming out of the updateAll() method but it seems to work fine. The fact the redirect
does not occur makes me think it is not returning.


I found the problem ! The method returns the number of rows updated rather than a model.
I started with a copy from another forum post....
I changed $model to $rows and the way I was using it....all good now.


public function releaseNew($id)
	{		
		$newStatus = 'NeedReview';
		$criteria = array(					
			'condition'=>' approve="New" and partner_id ='.$id , 			
		);
	        //$model = $this->updateAll(array('approve'=>$newStatus), $criteria);				
		//if ($model->validate())
                // $model->save();	
		$rows = $this->updateAll(array('approve'=>$newStatus), $criteria);				
		if($rows>0) 
		 $this->save();	
	}

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