Yii - 在空值的情况下比较密码失败的规则

时间:2015-03-12 08:37:18

标签: php validation yii passwords

我想创建一个页面来更改接受空值的用户密码:

<?php echo $form->labelEx($model, 'password'); ?>
<?php echo $form->passwordField($model, 'password',
                            array('maxlength'=>256, 'value'=>'', 'placeholder'=>'...')); ?>
<?php echo $form->error($model, 'password'); ?>

<?php echo $form->labelEx($model, 'password_repeat'); ?>
<?php echo $form->passwordField($model, 'password_repeat',
                            array('maxlength'=>256, 'value'=>'', 'placeholder'=>'...')); ?>
<?php echo $form->error($model, 'password_repeat'); ?>

这是比较密码的规则:

array('password', 'compare', 'compareAttribute'=>'password_repeat',
            'message'=>'xxx', 'allowEmpty'=>true,
            'on'=>'register, login, index'),
array('password_repeat', 'safe'),
array('password_repeat', 'length', 'max'=>256, 'tooLong'=>'...',
            'on'=>'register, index, login'),

问题是,当我将密码变为空时验证总是失败,为什么?

0 个答案:

没有答案