CodeIgniter Forums
Custom callback based on 2 fields - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Custom callback based on 2 fields (/thread-21604.html)



Custom callback based on 2 fields - El Forum - 08-15-2009

[eluser]Jhourlad Estrella[/eluser]
Hi, guys. My First time here. Anyway, I hope somebody can help me with my very simple problem with CI.


On my Login controller:

Code:
$this->form_validation->set_rules('f_username', 'Username', 'required|alpha_numeric|xss_clean|min_length[3]|max_length[12]');
$this->form_validation->set_rules('f_password', 'Password', 'required|min_length[8]|max_length[30]');

I am trying to find a way to make my login validation code ad CI compliant as possible so I want to do it using a custom callback function. Is there a place there I can do something to add a custom rule? I've already done this before without hassle but I lost all my codes recently.

Thanks in advanced!


Custom callback based on 2 fields - El Forum - 08-17-2009

[eluser]designfellow[/eluser]
Hi,
create a custom function with your code.
Add that function to validation rules with a prefix of 'callback_'
eg. callback_checkUnique
That's all Smile

Happy coding,
DesignFellow


Custom callback based on 2 fields - El Forum - 08-17-2009

[eluser]Neeraj Kumar[/eluser]
don't forget to add the validation function to your current controller Wink