CodeIgniter Forums
Form validation custom message - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Form validation custom message (/showthread.php?tid=61745)



Form validation custom message - albertfajarito - 05-13-2015

I'm using a Rule group for my form validation but I need a custom message for one of the rule. I tried looking through the documentation but nothing was mentioned about this type of use-case. Could anyone help me out on how to go about this: Form Validation -> Rule Group -> Custom Message


RE: Form validation custom message - paralogizing - 05-14-2015

$this->form_validation->set_message() ought to do the trick.


RE: Form validation custom message - techbat - 05-15-2015

Form Library provides set_message() method to set message on validate rule, even run CI native rule or custom created rule, see below example

PHP Code:
# required is rule name
# 2nd param for custom message and "%s" for field name.
$this->form_validation->set_message('required''%s required');