How To Redirect After Update

Hi everyone, I’m trying to redirect to admin view instead of normal view after my model has updated.

I tried this in my controller:

public function afterSave()










But it doesn’t work… could anyone help me?


first afterSave() is not a controller method so you cannot call it in your controller. It is a method of CActiveRecord see docs:

To redirect in your controller use $this->redirect(…) in your controller action right after saving your stuff. Refer to the docs on how redirect works:

It takes 3 parameters but you are most likely to use just the first one which is the url to redirect to. Give it a try now and let me know if it works.