edubob 2013-02-26 19:58:01 3317次浏览 2条回复 0 0 0
public function rules()
{
    return array(			
        array('username, password, password2, email, phonenum', 'required','message'=>' {attribute}不可为空.','on'=>'create'),
        array('username','length', 'max'=>20),
        array('username','unique'),
        array('password2','compare','compareAttribute'=>'password','message'=>' 两次输入的密码不一致..','on'=>'create'),
        array('email', 'email'),
        array('icon', 'safe'),
        // The following rule is used by search().
        // Please remove those attributes that should not be searched.
        array('id, username, password, email, phonenum', 'safe', 'on'=>'search'),
    );
}

请问类似的'on'=>'search',其中search是根据哪里来的,我有个方法是public function actionCreate(),那我应该写成 'on'=>'create’ 就可以了吗?还是应该怎么写?谢谢!

  • 回复于 2013-02-26 20:05 举报

    'on'=>'search'貌似只是下面的search方法。

    控制器里面的action方法的场景名字随便定义。例如你创建的时候 $model = new ZZZ('场景名');

    或者创建以后$model = new ZZZ();然后$model->setScenario('名字');

  • 回复于 2013-02-26 20:38 举报

    喔,明白了..谢谢!!

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