public function rules() {
// NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('id,groupid,identity_no,startdate,enddate,create_at,update_at', 'safe'), array('id,activecode,centerid,examdate,startdate,enddate,create_at,update_at', 'safe', 'on' => 'search'), ); } 这是什么意思呢?
这差不多是给指定的字段指定一种角色或者指定一个属性,类似于同样有点额“required”,这种的就是必填,“numeric”这种就是数字一样,因为对于yii的对象的属性赋值然后进行保存的时候会进行验证,如果字段在这个rules里面不存在,那么报错的时候这个字段对应的值是保存不进去的,
这个时候如果这个字段不想被验证,那么一般情况下就会放在safe里面,表示是安全字段。
-
谢谢!