Differences with Yii 1

Coming from a Yii 1 background and getting to grips with Yii 2, I noticed a few minor changes. For example:

  1. Scenarios. In Yii 1, there were two automatic scenarios - ‘insert’ and ‘update’. However in Yii 2 these scenarios do not exist and we have to write extra code to handle these.

  2. Captcha. In Yii 1, the Captcha image had a refresh link below it “get a new code”, but in Yii 2 there is no link. You have to click the image to refresh the Captcha but this isn’t entirely obvious.

  3. Required fields. In Yii 1, there was a ‘labelEx()’ function which automatically rendered an asterisk for required fields. However in Yii 2 this function no longer exists and we have to write our own code to get this back.

I think all of these features were very useful, does anybody know why they were changed?

Hi,

Yes, the Yii2 exist Scenarios, look this:

https://github.com/yiisoft/yii2/blob/master/docs/guide/structure-models.md#scenarios

http://www.bsourcecode.com/yiiframework2/yii2-0-scenarios/

Overall that’s because Yii 2.0 is a huge change in its codebase and lots of it was actually re-implemented from scratch. If something is missing, you can submit issue to GitHub and we’ll consider adding it back.

  1. There are CSS classes added to required fields so it’s easy to solve with some custom CSS.