Set validation message for a specific field? |
[eluser]Shpigford[/eluser]
Is there a way to do validation->set_message and change the name of the field? I have an input named "title" and if "title" is empty it says "The title field is required"...what I would like that message to say is "The site name field is required." How can I do that?
[eluser]cinewbie81[/eluser]
The following will works Code: $rules['title'] = "required";
[eluser]Shpigford[/eluser]
Doesn't that change the actual contents of the input? I just want to change what the error message says.
[eluser]daniel.affonso[/eluser]
It was not working for me too. I was using this before: Code: $this->validation->set_fields($this->fields); I change for this and now works: Code: $fields = $this->fields; @Shpigford: I hope this is help you. ps.: I think here we are free to change and share knowledge and not to impose truths...
[eluser]cinewbie81[/eluser]
Not sure how do u mean "not to impose truths" ... but my code definitely works .. at least it's works for me .. have a look at the help file
[eluser]daniel.affonso[/eluser]
Hi, Quote:at least it’s works for me That's the point... You are RIGHT, but the user guide examples not works for all situations. And, finally, I ask excuses for anything. Thanks.
[eluser]dootzky[/eluser]
i think this is the key explanation from the help file: Quote:The array keys are the actual names of the form fields, the value represents the full name that you want shown in the error message. full link: http://ellislab.com/codeigniter/user-gui...ation.html search the headline: "Re-populating the form" i think you'll get it then. i got mixed up just like Shpigford on the first glance, but this forum and totally sexy documentation helped me out. great stuff. cheers, CI rulzs. d.
[eluser]aataqwa[/eluser]
your change file system/language/english/validation_lang.php sory, my english bad.
[eluser]Bramme[/eluser]
Or you just go with the first reply, which is exactly what the topic starter wanted... Why the hell do you make things so complicated? |
Welcome Guest, Not a member yet? Register Sign In |