• Yii model rules使用


    今天使用model rules 里面的 on 发现死活不起作用,后来搜索发现 需要设置model 实例的 scenario 属性才能起作用,不知道为什么。

    //控制器内	
    
    $model = new User();
    $model->scenario = 'add'; //模型内 public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('username, password', 'required','message'=>'不能为空','on'=>'add'), array('username, password, salt, email', 'length', 'max'=>128), //array('profile', 'safe'), array('password_re','compare','compareAttribute'=>'password','message'=>'密码必须一致!','on'=>'add'), array('username','unique','message'=>'用户名已存在'), //array('addtime','default','value'=>time()), //array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), ); }

      

  • 相关阅读:
    js选项卡
    js 逻辑运算符
    git 标签管理
    git多人协作
    git 分支强制删除
    git bug修复
    DOS命令编译JAVA程序
    JDK的安装与配置
    我在linux的第一个C程序
    看我如何在控制台一行显示几万字符。
  • 原文地址:https://www.cnblogs.com/yxbs/p/3614253.html
Copyright © 2020-2023  润新知