编写验证两个输入(必须是 eqeal)的密码验证器的好方法是什么,以及如何将其集成到 zf2 表单中。

最佳答案

有一个“相同”验证器可以检查两个字段是否相等,它可以在表单构造函数中按以下方式使用:

$this->add(array(
    'name' => 'password', // add first password field
    /* ... other params ... */
));
$this->add(array(
    'name' => 'passwordCheck', // add second password field
    /* ... other params ... */
    'validators' => array(
        array(
            'name' => 'Identical',
            'options' => array(
                'token' => 'password', // name of first password field
            ),
        ),
    ),
));

关于php - 为 zf2 实现密码验证器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13476282/

10-09 23:55
查看更多