Safe if boolean check passes, otherwise not safe

Hello great Yii community!

I’ve run into a problem where I have some attributes that I would like a superuser to be able to change, but not regular users (ever). Right now, the attributes are specified as safe on search only, which means my superuser cannot change them.

Is there any way to add boolean info to the safe check, something like this?

array(‘account_id’, ‘safe’, ‘on’=>‘update’, ‘if’=>Yii::app()->user->isSuperUser()),

Sorry if this is a dumb question, but I appreciate any help. I feel like I should know this, but this is the first time I’ve run into it.

You can use different scenarios for regular and admin users and define different rules for them. Then after you create your model you set the right scenario and you’re done. Maybe read this page (again):

Since CModel.rules() is a method, you can put any logic there:

if (Yii::app()->user->isSuperUser())

    return array(...); // Rules for a super user.


    return array(...); // Rules for other users.

Wow. My question was a serious can’t see the forest through the trees kind of moment. Derp derp.

Thanks man!