sxtuwy 2011-09-24 16:02:17 4221次浏览 5条回复 0 0 0
public function rules()
{
    return array(
        // name, email, subject 和 body 是必填的
        array('username,password, confirmPassword,email, profile', 'required'),
        // email 必须是有效的email地址
        array('email', 'email'),
        array('password', 'compare', 'compareAttribute'=>'confirmPassword','on'=>'register'),
        array('profile', 'safe'),
        array('username','unique','className'=>'User'),
        array('image','file','types'=>'jpg,gif,png','maxSize'=>'524288'),
        // verifyCode 需要输入正常
        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
    );
}

image字段并不要求,但是提示必须?为什么?

  • 回复于 2011-09-24 16:03 举报

    四哥威武....

  • 回复于 2011-09-24 16:07 举报

    这个要看你表单哪些要填哪个不要填 这个要自己定制的

  • 回复于 2011-09-24 16:28 举报

    就是这里没有设置image为必须

    array('username,password, confirmPassword,email, profile', 'required'),
    array('image','file','types'=>'jpg,gif,png','maxSize'=>'524288','allowEmpty'=>true),
    

    这里如果没有'allowEmpty'=>true的话,就是提示图片必须,但是并不显示星号

  • 回复于 2011-09-24 16:29 举报

    邮件必填,不提示星号!

  • 回复于 2011-09-24 16:46 举报
    array('image','file', 'allowEmpty'=>true,'types'=>'jpg,gif,png','maxSize'=>'524288')
    

    问的是这个吧? 默认是需要输入的。

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