Handling Phalcon/Validations

when i am validating a form i want to stop validations when any of the validation fails for the respective input variable for that i had used "cancelOnFail" => true.....But what it actually does is it doesn't check validations for other input variables if the first input variabe fails............................

                                // Password
            $password = new Password('password', [
                "maxlength" => 8,
            $password->setFilters(array('striptags', 'string'));
            $password->setAttribute('class', 'form-control');
                new PresenceOf(array(
                    'message' => 'Password is required',
                    "cancelOnFail" => true,
                new StringLength(array(
                    'min' => 8,
                    'messageMinimum' => 'Minimum length of password should be atleast 8',
                    "cancelOnFail" => true,

            // repeatPassword
            $repeatpassword = new Password('repeatPassword', [
                "maxlength" => 8,
            $repeatpassword->setAttribute('class', 'form-control');
            $repeatpassword->setFilters(array('striptags', 'string'));
            $repeatpassword->setLabel('Repeat Password');
                new PresenceOf(array(
                    'message' => 'Please Re-Enter your password',
                    "cancelOnFail" => true,
                new Confirmation(array(
                    'message' => 'Passwords doesn\'t match',
                    'with' => 'password',
                    "cancelOnFail" => true,

so when i try submit this form i should get error messages for password=Password is required and for repeatpassword Please Re-Enter your password.........i e it should not check the other validations of each input variable............. when but i use "cancelOnFail" => true, i just get validation msg for password and it stops there itself.....how can i validate the whole variables and stop validations for each variable when fails....?

Please help..!!!!!!!!!!!

edited Mar '17

You question doesn't make sense as it's currently written, I think. As I read it, you want to run a validation on input, and stop when a validation rule fails and return the error, but at the same time check all other validation rules?

Are you able to give us some input (case scenarious of what $this->request->getPost("password") holds) and desired output examples? IE:

| Input           | Output                                            |
|--------------   |------------------------------------------------   |
| (string) ""     | Password is required                              |
| (string) "f"    | Minimum length of password should be atleast 8    |

Suppose if i gave an input for

  • password = NULL *repeatpassword = NULL

then i should get errormsgs as for password i should get "Please reenter the password" and for repeat password i should get "Please reenter the password" i.e FOREACH input in form it should check one validation at a time and stop other validations when a validations fails ......

He just means that cancelOnFail should stop validation only for field, not for whole validation, i think there is an issue existing like this in phalcon to add such ability.

Yes, add such a feature to phalcon.