Creating Custom Form Validation

#1
[eluser]opel[/eluser]
I know Codeigniter has the ability to make custom form validation in controllers as callbacks but is there a way to make up global custom validation functions ?

What I am trying to do is use a function I created as a plugin to filter some $_POST data. Instead of me having to manually do something such as :

Code:
$_POST['name'] = plugin_function($this->input->post('name'));

I would like to have something like :

Code:
$this->form_validation->set_rules('name', 'name', 'trim|plugin_function|xss_clean');

is this possible without having to put callback_plugin_function in every controller ?

#2
[eluser]Evil Wizard[/eluser]
yeah, extend CI_Controller with My_Controller, put the callback function if there and then get your specific controllers to extend My_Controller and they will inherit the callback method

#3
[eluser]opel[/eluser]
thank I have a base controller that I extend everything from so I will put it in there.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.