这是在edit方法里重写
staff是表名,username是字段名,$ids是当前数据的id
try { //是否采用模型验证 if ($this->modelValidate) { $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException(true) ->validate( [ 'username|用户名' => [ 'require', 'alphaNum', 'length:6,25', 'unique' => 'staff,username,' . $ids . '' ], 'password|密码' => ['require', 'alphaNum', 'length:6,25'] ] ); // $row->validateFailException(true)->validate($validate); } $result = $row->allowField(true)->save($params); Db::commit(); } catch (ValidateException $e) {