Custom error message for all rules |
Hi there!
I was looking for a way to use a single error message in the validation class for all rules. I managed to do it with few changes in system/Validation/Validation.php The following lines in function setRules can be modified like this: -- Original -- PHP Code: if (array_key_exists('errors', $rule)) { -- Modified -- PHP Code: if (array_key_exists('errors', $rule) && is_array($rule['errors'])) { And also function getErrorMessage: -- Original -- PHP Code: // Check if custom message has been defined by user -- Modified -- PHP Code: // Check if custom message has been defined by user I hope you will find this useful and this future find its way to the official release. (05-23-2024, 10:38 PM)semprom Wrote: Hi there!The official way to get this considered is to submit a PR in GitHub. (05-24-2024, 03:26 AM)Bosborne Wrote:Well not according to GitHub.(05-23-2024, 10:38 PM)semprom Wrote: Hi there!The official way to get this considered is to submit a PR in GitHub. Quote:Please submit feature requests to our [forum](https://forum.codeigniter.com/forum-29.html).
Right. If this is a discussion, then go to the forum. If you create a feature, test it and describe why you need it, you send a PR on github.
And please don't quote half-page posts. Your wish can be done differently. For example, after validation in the controller, you can check "if there are errors", clear them and send a new error as setError() |
Welcome Guest, Not a member yet? Register Sign In |