We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Form validation - skip/allowEmpty - Phalcon 2.0.6

This is not working in Phalcon 2.0.6 . Sample code (I want to skip password validation on edit):

    protected function addPasswordElement()
    {
        $password = new Text('password');

        $password->addValidators([
            new PresenceOf([
                'message' => 'Password is required',
                'allowEmpty' => true,
                'cancelOnFail' => true
            ]),
            new StringLength([
                'min' => 8,
                'messageMinimum' => 'Password is too short. Minimum 8 characters',
                'allowEmpty' => true
            ]),
            new Confirmation([
                'message' => 'Password does not match confirmation',
                'with' => 'confirmPassword',
                'allowEmpty' => true
            ])
        ]);

        $this->add($password);
    }

    protected function addConfirmPasswordElement()
    {
        $confirmPassword = new Password('confirmPassword');

        $confirmPassword->addValidators([
            new PresenceOf([
                'message' => 'Confirmation password is required',
                'allowEmpty' => true,
                'cancelOnFail' => true
            ])
        ]);

        $this->add($confirmPassword);
    }

from docs

 * Phalcon\Validation\Validator\PresenceOf
 * Validates that a value is not null or empty string

doesn't really make sense to allow empty while you use PresenceOf to don't accept empty