hey, can I redirect page from model.
here is my condition
if ($test) {
$this->redirect(array(‘good’));
} else {
$this->redirect(array(‘bad’));
}
I want to redirect the page from model not controller. is that possible?
hey, can I redirect page from model.
here is my condition
if ($test) {
$this->redirect(array(‘good’));
} else {
$this->redirect(array(‘bad’));
}
I want to redirect the page from model not controller. is that possible?
I think it has no sense. In any case, $this refers to model, instead of controller, and redirect is a controller’s method not model’s one.
What do you wanna do in specific?
You should never do this in a model, as this breaks the basic MVC principles. Nevertheless it’s possible:
Yii::app()->request->redirect(..);
Thanks
Mike is right, better avoid to do it in the model.
Is better to do a function test in the model, then check this function in the controller and redirect.