CodeIgniter Forums
Form_validation message[SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Form_validation message[SOLVED] (/thread-30829.html)



Form_validation message[SOLVED] - El Forum - 05-27-2010

[eluser]Ivar89[/eluser]
Hi,
I have a contact form with some required fields And standard induvidual message is:
The "field name" field is required.

Now I want to change it to something else...and its not working
I need to change every field induvidually and if I use:
Code:
$this->form_validation->set_message('required',  'Niet alle velden zijn correct ingevoerd.');
It changes ALL fields with the rule required to that message
but is there a way I can set a message not connected to a rule but to like an ID??
I can't find this in the user guide.

Thanks in advance.


Form_validation message[SOLVED] - El Forum - 05-27-2010

[eluser]steelaz[/eluser]
You can create validation callback function for this particular field and set your own message.


Form_validation message[SOLVED] - El Forum - 05-27-2010

[eluser]Ivar89[/eluser]
OMG so simple ofcourse!Tongue
I only used callback to validate if a field was true or falseTongue

but eeuhm its about 6 fields or so...then I have to make 6 function just for that...


Form_validation message[SOLVED] - El Forum - 05-27-2010

[eluser]cahva[/eluser]
Excuse me, but why do you want to change required message different for every field? Doesnt make sense. If you meant that you dont have the field name when you use set_message? Do you just need to translate the text to your language? Then add your own language to system/language/[your language]/form_validation.php

..or (havent tested this) use the placeholder(%s) in your message:
Code:
$this->form_validation->set_message('required',  '%s Niet alle velden zijn correct ingevoerd.');



Form_validation message[SOLVED] - El Forum - 05-27-2010

[eluser]Ivar89[/eluser]
cahva saved my day:p

thanks