zoukankan      html  css  js  c++  java
  • 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()), ); }

      

  • 相关阅读:
    常用的正则表达式
    Spring
    Hibernate-04
    Hibernate-03
    Hibernate-02
    Hibernate-01
    装饰器(python)
    软件工程之小组选题报告
    小组项目之需求分析与原型设计
    关于group_concat函数拼接字符超长的问题
  • 原文地址:https://www.cnblogs.com/yxbs/p/3614253.html
Copyright © 2011-2022 走看看