![]() |
Custom error message - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Custom error message (/showthread.php?tid=26895) |
Custom error message - El Forum - 01-26-2010 [eluser]jakeone[/eluser] Hi I'm validating my form using an array as shown in the user guide, i.e. Code: $config = array( Can someone tell me the correct syntax to create a custom an error message for each rule? Yes, I know I can use Code: $this->form_validation->set_message('rule', 'Error Message'); Thanks Custom error message - El Forum - 01-27-2010 [eluser]codeshadow[/eluser] Hi, Do you mean to say that just like the $config array you wish to have one more array that would hold your custom error messages? Well if it is so, then try this: Code: $mess = array('required' => 'You gotto add something to this dude', And then pass it to set_message() just like the way you pass an array to set_rules: Code: $this->form_validation->set_rules($mess); There you go, all your custom messages in one array :coolsmile: Custom error message - El Forum - 01-28-2010 [eluser]jakeone[/eluser] It's not quite what I meant - sorry I should have been clearer. What I mean was, is there an array key I could set to hold a custom error message when using an array to process the validation, e.g. Code: $config = array( Not sure if this is possible. Thanks Jake |