Form validation by my own method |
You can always extend the Form_validation library and add your custom rules which would be accessible anywhere the form_validation library is used.
http://www.codeigniter.com/user_guide/ge...-libraries /application/libraries/MY_Form_validation.php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Then in your controller(s): PHP Code: $this->form_validation->set_rules('fieldname', 'field text', 'trim|custom_rule'); You can also create rules that receive extra parameters, which are passed in between the [] when setting the rule, like "min[5]". Anything in [] will automatically be passed to your rule definition as a 2nd parameter PHP Code: function some_rule($input, $extra = '') if you used: PHP Code: $this->form_validation->set_rules('fieldname', 'field text', 'trim|some_rule[something here]'); If you look at how they are creating the native rules in the /system/libraries/Form_validation.php, it could be helpful when creating your custom rules. |
Messages In This Thread |
Form validation by my own method - by Valery - 04-25-2015, 09:07 AM
RE: Form validation by my own method - by lexxtoronto - 04-26-2015, 11:30 AM
RE: Form validation by my own method - by Valery - 04-28-2015, 04:20 AM
RE: Form validation by my own method - by RogerMore - 04-27-2015, 12:23 AM
RE: Form validation by my own method - by Valery - 04-28-2015, 04:12 AM
RE: Form validation by my own method - by mwhitney - 04-28-2015, 10:19 AM
RE: Form validation by my own method - by lexxtoronto - 04-28-2015, 10:51 AM
RE: Form validation by my own method - by CroNiX - 04-28-2015, 11:33 AM
RE: Form validation by my own method - by Valery - 04-29-2015, 07:03 AM
|