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

How to change the default validation messages in Phalcon 4?

In Phalcon 3, there was an option to set the default validator messages with this:

$validation->setDefaultMessages($defaultMessages);

This is removed in Phalcon 4.

This was extremely useful. I could set the default messages based on the current language.

In Phalcon 4, the only way to do this is by by providing the message manually when adding a Validator. This is extemely cumbersome and redundant. I litterally have thousands of form fields that would need to be refactored for this.

Is there any way I could solve this?

Hello, Thank you for the information, this was really useful. I would also like to recommend Solar Panel Cost Price to the people of Perth who are looking for the top solar panel agencies in Perth WA. top solar PV system installers in Perth

edited Dec '20

t is all about reusability. You might want to add the same form in different places, so it will be the same. At the first look it seems like a lot of extra work, but later it will help you out. It is comparable to unit tests. At first it looks like extra work, but later on it will helpmy milestonecard



2.5k

t is all about reusability. You might want to add the same form in different places, so it will be the same. At the first look it seems like a lot of extra work, but later it will help you out. It is comparable to unit tests. At first it looks like extra work, but later on it will help.

Re-using a form or not is irrelevant to my question.

I have thousands of different form fields scattered around dozens of websites. For example, every time I use "PresenceOf", I have to manually add the message I want to display when the field is empty. I just want it to have that message by default.