Tag: scenarios

Safe attributes tip

February 19th, 2009, No Comments

In my last two posts [1, 2] I explained how to define scenario-based validation rules and safe attributes. Something I have noted is that whenever I end up specifying an attribute as “required” in the validation rules(), I also always end up specifying it as “safe” in safeAttributes() under the same scenario. This got me […]

Safe attribute scenarios

February 17th, 2009, 3 Comments

If you read my last article on validation scenarios then you may understand why in different scenarios you may need different attributes to be required. However you may have noticed a missing link – what if in different scenarios you also need different attributes to be considered as “safe”? If you have no idea about […]

Validation scenarios

February 16th, 2009, 16 Comments

As of Yii 1.0.2 you may now define validation scenarios. This is very useful if for instance you have multiple places in your application that you validate a model, but in each instance you may want different validation rules. For instance, perhaps in your user registration form you want to have the “username”, “email” and […]


http://php-thoughts.cubedwater.com / scenarios