CodeIgniter Forums
CI can't access 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: CI can't access error message. (/showthread.php?tid=14765)



CI can't access error message. - El Forum - 01-14-2009

[eluser]doktorcivanim[/eluser]
Hi,

I am working on a form and have two problems.

My first is, I have a custom validation function, it is correctly called, but I cannot get the parameter. I only get the name of the parameter I give (['username'] gives the value 'username').

To ressolve this, I used the $this->input->postfunction to get the parameter.

The second problem is that when giving an error (set_message) I get "Unable to access an error message corresponding to your field name." What is wrong?


My function and declaration of rules:
Code:
//Rules
$this->form_validation->set_rules('begin_date', 'Begindate', 'callback_checkBeginDate[end_date]');
$this->form_validation->set_rules('begin_date', 'Enddate');


//Custom rule
function checkBeginDate($beginDate,$endDate){
...
$this->form_validation->set_message('begin_date', 'Enddate must be bigger or equal to begindate');
...

...

Thanks.


CI can't access error message. - El Forum - 02-22-2009

[eluser]Xollef[/eluser]
You should probably use rule name instead of field when assigning error messages.

Try something like:
Code:
$this->form_validation->set_message('checkBeginDate', 'Enddate must be bigger or equal to begindate');