Yii CModel.rules() 方法 validate预定义完整列表

array(
  array('username', 'required'),
  array('username', 'length', 'min'=>3, 'max'=>12),
  array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'),
  array('password', 'authenticate', 'on'=>'login'),
  array('Price','numerical', 'integerOnly'=>true),
);
public function rules()
{
   return array(
       array('title, content, status', 'required'),
       array('title', 'length', 'max'=>128),
       array('status', 'in', 'range'=>array(1,2,3)),
       array('tags', 'match', 'pattern'=>'/^[\w\s,]+$/',
           'message'=>'Tags can only contain word characters.'),
       array('tags', 'normalizeTags'),
       array('title, status', 'safe', 'on'=>'search'),
   );
}






预定义完整列表:

Meet so Meet. C plusplus I-PLUS....
原文地址:https://www.cnblogs.com/iplus/p/4489994.html