我有一个的CActiveRecord模型,我需要改变这种模式的安全属性列表。 我已经定义了safeAttributes方法我的模型内,如下所示:

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

问题是“生物”是不是我的安全属性分配正在考虑中。我企图把模型safeAttributeNames在我的模型属性,和我所得到的是从safeAttributes应该返回什么完全不同的。

我在正确的方式做这个?

欢呼声, Firas

有帮助吗?

解决方案

假设你使用Yii 1.0.x的话就是这样做的正确方法。

如果您正在使用Yii 1.1.x版本那么它的变化。有href="http://www.yiiframework.com/doc/guide/form.model" rel="nofollow noreferrer">文档的

public function rules()
{
    return array(
        array('username, password', 'required'),
        array('rememberMe', 'boolean'),
        array('password', 'authenticate'),
        array('something', 'safe'),
        array('someOtherThing', 'unsafe'),
    );
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top