a3522665 2013-01-07 17:23:56 2251次浏览 4条回复 0 0 0
return array(
    array('username, password, sid', 'required'),
    array('sid, state', 'numerical', 'integerOnly'=>true),
    array('username, password', 'length', 'max'=>50),
    // The following rule is used by search().
    // Please remove those attributes that should not be searched.
    array('id, username, password, sid, state', 'safe', 'on'=>'search'),
);

这里的 'on'=>'search' 这句是什么意思
是不是 在search 方法下 'id, username, password, sid, state', 'safe' 不能为空?

假如 state 这个字段 在特定的情况下 让他为空 应该怎么写

  • 回复于 2013-01-07 18:02 举报

    是指在search场景下。

  • 回复于 2013-01-08 08:11 举报

    就是在search的时候,才进行那个验证。

  • 回复于 2013-01-08 08:50 举报

    你好 3Q 我再问下 假设设定一个字段不能为空, 如果我要指定 某一个页或者某一个controller里的一个方法 下才使用这个规则
    可以吗 应该怎么写 谢谢

  • 回复于 2013-01-08 10:47 举报

    array('username, password, sid', 'required', 'on'=>'update'),可以这样试试。

您需要登录后才可以回复。登录 | 立即注册