Validation error message is missing the field name |
[eluser]SouthOfZeeland[/eluser]
Howdy! I have a problem with the validation error message. When I submit a form, and a required field is missing, the error message should read "Title is a required field". But the error message I get is "is a required field". I have made sure that my input-field has the same 'name' as my $rules['name'] and $fields['name']. The standard error message is "%s is a required field". Any idea what I'm doing wrong? TIA
[eluser]gtech[/eluser]
Hello its very difficult to see without your code whats going on.. I tried following the example from the validation documentation and the %s worked fine for me, maybee you could cut and copy the code examples, especially the controller in "Callbacks: Your own Validation Functions". Then you can satisfy yourself it works. the following code also worked for me (slightly modified from documentation) Code: function index() views/myform.php Code: <html> resulting in Code: password custom message here
[eluser]SouthOfZeeland[/eluser]
Controller: Code: $rules["title"] = "required|max_length[255]"; View: Code: <?php echo $this->validation->error_string; ?> That's my code. The value in the lang-file is Code: $lang['required'] = "The %s field is required.";
[eluser]gtech[/eluser]
humm I see what you mean.. the set_fields seems to be overwriting the set_rules, if you take the set_fields out it works.. let me have a play with the code..
[eluser]gtech[/eluser]
OK I have an answer but not sure you will like it :-( When using set fields the $fields["title"] bit has the text string of what will appear in the error message (it will be substituted in the %s bit of your default error message). The value that appears in your textinput box will be your the post result NOT what you set $fields["title"] to. Hope that helps :-) it confused me. Code: <?php
[eluser]SouthOfZeeland[/eluser]
Ah, now I see! It works now! Thanks a bundle! |
Welcome Guest, Not a member yet? Register Sign In |