removal of safeAttributes ...

Hi all (and the yii team especially ;)

I was updating to last rev to benefit from bug fixes and had troubles with my beforeValidate functions and my custom safeAttributes function

I saw that they were major changes in this area

from what I read safe attributes now have to be tied to a validation rule

would you explain this choice and how can I massively assign custom attributes with no validation rules ?

thanks in advance

Pleas refer to this topic: http://www.yiiframew…pic,2097.0.html

Be warned if you are using the trunk code because it may introduce new changes like this that may break your code completely. You may switch to 1.0 branch if you are working on some big project that needs more stable codebase.

thanks qiang,

I thought branches/1.0 was the developement branch and that you were merging to trunk from this branch when all was considered stable

So if I understand right :

I f I have a custom attribute that I want to be massively assigned I need to declare it in rules() with an actual rule of the 'safe' rule if I don't want it to be validated

did I get it right ?

Yes, you are right. The 'safe' rule is designed for this purpose. Combining with 'unsafe' rule, the new safe attribute scheme should be able to implement the old safeAttributes() scheme.

If you want an attribute to be unsafe only in a certain scenario, this seems to work:



array('B','unsafe','on' => 'registration'),

My question: is this ok? Will the unsafe validator always take precedence?

Yes, unsafe always takes precedence.

Will this change be included in any release soon?

Nope. This will only be available in 1.1 release since it introduces some big compatibility changes.