Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Rules() -> Safe -> Opinion!

$
0
0
Hello guys, i need some clarification/opinion about the 'safe' rule on attributes.

I'm seeing some people using 'safe' on created/updated attributes for insert/update scenarios.
As you know, we should only define rules for attributes that will receive user inputs. Also the massive assignment it's only applied for those attributes that have at least one rule.

My question is, do i really need to define rules for those attributes (created/updated/id from related table/etc), when i'm using them on the beforeSave method or in any other method that i can use for the purpose?

If the application assigns the value, why should i define rules for those attributes?

Personally i think that doesn't make any sense using safe here. Why the user should insert the value? For that we have the beforeSave()/other methods.

To prevent some errors from my part, I just want to know if I'm right in what im saying or if i miss something here?

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>