Using Scenarios In Yii


I’m new to Yii framework. I started working on it few days back.

Now I’m working on a demo application wherein I have user registration and user login.

As I went through few documentation on Yii I found out that one needs to use Scenarios for Login/Registration while specifying rules in the model.

So can someone help me to understand what scenarios are…??..And how does one can define custom scenarios…??

Please explain with some example module so that I can understand it better.

I tried to implement scenarios but I found that the validate() function in controller is not working.

It would be nice if someone could help me regarding this matter.


  1. The very good explanation on Yii scenario you can find here

  2. Try to debug your scenario step by step, making the Yii::log(‘Ok …’), in every function that should be called.

  3. And then post the results here. Without the detailed information of your issue it will be difficult to help you.

Thank you for your suggestion. I’ll work on it.