{field}, {param} and {value} tags not working in model validation? |
I searched a few different terms but could not locate the answer so I apologies if this has already been covered.
I am using the CodeIgniter 4 Model validation rules PHP Code: protected $validationRules = [ I created a validation rule for "short_name" and attached it to CI4 and just to test if anything was working I added all of the tags indicated on here: https://codeigniter.com/user_guide/libra...r-messages (I have provided just the short_name validation function below) PHP Code: public function short_name(string $str, string &$error = null): bool I know it's working because it returns the error like it should but it does not replace the tags at all? I am literally getting "{field}, {param} and {value} must only contain uppercase letters." I am calling the model validation from the REST resource controller type with PHP Code: public function update($id = null) Is the model class not building and/or handling the validation rules attached to it correctly or am I missing something else? https://codeigniter.com/user_guide/model...ating-data
Change your single quotes to double quotes.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
InsiteFX unfortunately that didn't change anything it is still showing {field}, {param} and {value} must only contain uppercase letters. in my error dialog
Try this:
PHP Code: protected $validationRules = [
It looks like the tagging only works if you have the entry in the language Validation.php file in my case at ./app/Language/en/Validation.php
it totally disregards tags in the $error = '' variable reference inside the validation rule? Seems pointless to even supply that then except for the most basic errors? "On this form 1 or more fields should contain only uppercase letters." -- I mean this jokingly of course. Should this be filed as a Bug?
Have you tried my suggestion?
Based on the code of Validation, if the error string in the custom validator function is not null, it will be fetched right away and returned immediately (No replacements of placeholders to be made). So you need to pass in your custom errors beforehand. |
Welcome Guest, Not a member yet? Register Sign In |