0

I need to check that a typed in password is what the user thinks is typed in.

For this I ask for the password to be typed in twice.

I have some existing validation in place but nothing for multiple fields yet.

I wondered how to have the validator check its field against another field.

Wilt
  • 41,477
  • 12
  • 152
  • 203
Stephane
  • 11,836
  • 25
  • 112
  • 175
  • 2
    If you read the documentation of the validator you should've seen it. Pretty much to quick with asking a question instead of doing a good search about your problem. – Kwido Dec 05 '16 at 11:25
  • 2
    Possible duplicate of [Implementing a password validator for zf2](http://stackoverflow.com/questions/13476282/implementing-a-password-validator-for-zf2) – Kwido Dec 05 '16 at 11:27

1 Answers1

1

I could find the syntax for it: 'token' => 'password'

Here is the way to do it:

    array(
        'name' => 'password',
        'required' => true,
        'filters' => array(),
        'validators' => array(),
    ),
    array(
        'name' => 'passwordBis',
        'required' => true,
        'filters' => array(),
        'validators' => array(
            array(
                'name' => 'identical',
                'options' => array(
                    'token' => 'password',
                    'messages' => array(
                        \Zend\Validator\Identical::NOT_SAME => \Application\Util\Translator::translate('The two passwords must be identical')
                    )
                )
            )
        ),
    ),
Stephane
  • 11,836
  • 25
  • 112
  • 175