凯凯哥 2013-04-28 12:17:56 3242次浏览 0条回复 0 0 0

我想实现用户输入信息的时候进行验证,错误时,可以通过 $this->addError($attributes,'$message'); 来发送错误的信息 那么如果验证成功我怎么设置呢?

if($params['type']==='realName'){
	if($this->real_name != ""){
		//$match='/^[\x80-\xff]{4,18}$/';
		$match='/^[\x{4e00}-\x{9fa5}]{2,4}$/u';
		if(preg_match($match,$this->real_name)){
			$this->real_name=$this->real_name;
		}else{
			$this->addError($attribute, '真实姓名格式不正确!');
			return false;
		}
	}else{
		$this->addError($attribute, '真实姓名不能为空');
		return false;
	}
}
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册