Implementing a password validator for zf2

五迷三道 提交于 2019-12-21 19:28:13

问题


What is a good approach to write a password validator that validates two inputs (must be eqeal) and how would you integrate that into a zf2 form.


回答1:


There is an "Identical" validator that check two fields to be equal, it can be used in the following way in form constructor:

$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
            ),
        ),
    ),
));


来源:https://stackoverflow.com/questions/13476282/implementing-a-password-validator-for-zf2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!