We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Custom validate message is not showing

public function validation() {

    $this->validation(new EmailValidate(array(
        'field' => 'email',
        'message' => 'Please enter a valid Email address'
    )));

    when I submit the validator display "email is required" instead of "Please enter a valid Email address"


5.7k

I'm not sure if you've checked this yet but I've run into something similar before. When you're validating your form, are you testing it on a form that also actually saves/updates a record in the database?

Usually if you see the "{field} is required" error, it's a "PresenceOf" validator, either on the form or in a model. If you use the Email Address validator, it will validate when there is a value but is not a valid email. If there is a PresenceOf validator present but no value, it will throw that error frist. Just a thought that hopefully points you in the right direction.