Welcome Guest, Not a member yet? Register   Sign In
Confused with set_message validation function
#2

[eluser]charlie spider[/eluser]
if you write:

Code:
$rules['usernamefield']     = 'trim|required';
$rules['emailfield']         = 'trim|required';

then 'usernamefield' refers to a field name
and 'required' refers to a rule.

Code:
$this->validation->set_message('rule', 'error message');
allows you to write custom error messages for a specific rule, not a specific field name.

so you would write:

Code:
$this->validation->set_message('required', 'You must fill this field!');

not:

Code:
$this->validation->set_message('usernamefield', 'You must fill this field!');

but then any form input with the 'required' rule applied to it would receive the 'You must fill this field!' error message if it was left out upon the form being submited.

you can also use:

Code:
$this->validation->set_message('rule', 'error message');

to write a custom error message for a callback function, as long as you substitute 'rule' for the name of the callback function, like such:

Code:
$this->validation->set_message('callback function name', 'error message');


Messages In This Thread
Confused with set_message validation function - by El Forum - 06-27-2008, 07:07 AM
Confused with set_message validation function - by El Forum - 06-28-2008, 10:16 PM
Confused with set_message validation function - by El Forum - 06-30-2008, 06:12 AM
Confused with set_message validation function - by El Forum - 07-13-2008, 10:35 PM
Confused with set_message validation function - by El Forum - 07-13-2008, 10:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB