TP3.2.3里$_POST数据经过create()方法处理后,数组为空

浏览:4428 发布日期:2016/12/23 分类:求助交流 关键字: TP3.2.3 create() 自动验证
public function register(){
    
        $user_model=D('User');
        if(!empty($_POST)){
            $data=$user_model->create(); 
            dump($_POST);die;
$user_model=D('User');
        if(!empty($_POST)){
            $data=$user_model->create(); 
            dump($data);die;

$errorInfo=$user_model->getError();$errorInfo变量为空。以下是模型类里对自动验证的定义:
// 是否批处理验证
protected $patchValidate = true;
// 自动验证定义
//array(被验证的字段,验证规则,错误提示,[验证条件,附加规则,验证时间]);
 protected $_validate =   array(
        array('username','require','用户名不能为空',1),
        array('username','','用户名已经存在',1,'unique'),
        array('password','require','密码不能为空',1),
        array('password2','require','密码不能为空',1),
        array('password2','password','两次密码不一致',1,'confirm'),
        array('user_email','email','邮箱格式不正确',1),
        array('user_email','','该邮箱已被注册',1,'unique'),
        array('user_qq','number','QQ号码只能是数字',2),
        array('user_qq','5,12','QQ号码长度在5-12位之间',2,'length'),
        array('user_tel','11','手机号长度为11位',2,'length'),
        array('user_xueli','2,5','学历是必填选项',2,'between'),
        array('user_hobby','check_hobby','兴趣必须选两项以上',1,'callback'),
    );  
    
    public function check_hobby($arg) {        
        if(count($arg<2)){
            return false;
        }else{
            return true;
        }
    }
请解决了相关问题的高手指点迷津!
最佳答案
评论( 相关
后面还有条评论,点击查看>>