Redirect does not work, I don’t know why, below is the brief code:
public function actionUpdate($id)
{
Yii::app()->language = 'zh_cn';
$model=$this->loadModel($id);
if(isset($_POST['DYClass'])) {
$model->save();
$this->redirect(array('schedule')); // it didn't redirect after save
}
$this->render('update',array(
'model'=>$model,
));
}
Yes, I am sure that isset($_POST[‘DYClass’]) is true, because I tried replacing the redirect code with just “return”, it will return to a blank page.
After submit, it stayed on the update page, didn’t redirect to any other page and didn’t show any error.
The more weird thing is that if I replace the redirect code with echo and return as below, it didn’t return to a blank page with “ok” text either, just stayed on the update page.
public function actionUpdate($id)
{
Yii::app()->language = 'zh_cn';
$model=$this->loadModel($id);
if(isset($_POST['DYClass'])) {
$model->save();
echo "ok";
return;
}
$this->render('update',array(
'model'=>$model,
));
}