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

Custom Form Validation Class

Hi all, the scenario is a complex form where validation is conditional. I've some form fields which became mandatory when other fields match something.

I've written the entire form definition and i've defined validators only for alway-mandatory questions. Now i'm going to approach to define a custom validation class (where i may move above validators from form class) where define a custom validation continuation in afterValidate method.

How can i tell my form to use my custom class as internal validator? I need to use the form to access validation results since this is the way my templates are written. Moreover i can't understand how to add a message to its specific element to be retrieved later from the form element in the view.

Thanks Gianluca

you want to build a form class ?