相关疑难解决方法(0)

如何在Yii2中定义场景?

我的模型规则是这样的

public function rules()
        {
            return [
                [['email','password'], 'required'],
                [['email'],'unique'],
                [['status','role_id','created_by', 'updated_by', 'is_deleted'], 'integer'],
                [['created_at', 'updated_at'], 'safe'],
                [['first_name', 'last_name', 'email', 'username','location','address','about_me'], 'string', 'max' => 200],
                [['phone'], 'string', 'max' => 100]
            ];
        }
Run Code Online (Sandbox Code Playgroud)

在创建新用户时我需要电子邮件和密码,但在更新期间我只需要用户名.我怎样才能做到这一点?

yii2

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

yii2 ×1