开发者

how to change a model safe attributes in yii

I have a CActiveRecord model, and I need to change safe attributes list in that model. I have defined the safeAttributes method inside my model, lik开发者_运维知识库e the following :

public function safeAttributes()
{
    return array(
    'name, bio',
    );
}

the problem is 'bio' is not being considered in my safe attribute assign. I tried to dump the model safeAttributeNames attribute in my model, and what I've got was completely different from what safeAttributes should return.

Am I doing this in the right way ?

cheers, Firas


Assuming that you are using Yii 1.0.x then that is the correct way to do it.

If you are using Yii 1.1.x then it's changed. Have another read of the documentation.

public function rules()
{
    return array(
        array('username, password', 'required'),
        array('rememberMe', 'boolean'),
        array('password', 'authenticate'),
        array('something', 'safe'),
        array('someOtherThing', 'unsafe'),
    );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜