My Form validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: My Form validation (/showthread.php?tid=47843) |
My Form validation - El Forum - 12-24-2011 [eluser]Unknown[/eluser] Hello I want to create my form validation. This is libraries/my_form_validation.php: Code: <?php And use controler method Code: $this->load->library('form_validation'); My form valdiation is not work. I test preg_match in test.php(outside ci) and add some text and work, no problem but in codeigniter not receive Where am I wrong? Thank you My Form validation - El Forum - 01-21-2012 [eluser]Unknown[/eluser] The only thing I see would be that you are calling set_rules from the main CI validation library and not your custom one. It should probably look like this: Code: $this->my_form_validation->set_rules('newstitle', 'News title', 'trim|required|min_length[10]|validation_text[newstitle]'); My Form validation - El Forum - 01-21-2012 [eluser]CroNiX[/eluser] In validation_text(), it doesn't know what $CI is...$CI should be $this->CI. Additionally, CI always first looks for a MY_whatever, so there is no need to manually load it. Just load form_validation and it will automatically load MY_Form_validation. My Form validation - El Forum - 02-11-2012 [eluser]moth[/eluser] I've been having much the same problem, except that instead of declaring my validation rules directly in my Controller methods, I've moved them to a config file in /application/config/form_validation.php Is there a gotcha in combining MY_Form_validation with Config-based rules? I just can't seem to get it to work. My Form validation - El Forum - 02-11-2012 [eluser]InsiteFX[/eluser] it should be saved as ./application/libraries/MY_Form_validation.php My Form validation - El Forum - 02-11-2012 [eluser]moth[/eluser] It is. I have; /application/config/form_validation.php (as described here: http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#savingtoconfig) ..and /application/libraries/MY_Form_validation.php -- /application/libraries/MY_Form_validation.php Code: class MY_Form_validation extends CI_Form_validation { /application/config/form_validation.php Code: $config = array( My Form validation - El Forum - 02-11-2012 [eluser]moth[/eluser] MY_Form_validation Loads - I see my debug message, I just don't get any validation... My Form validation - El Forum - 02-11-2012 [eluser]moth[/eluser] Ok, it looks like the rules weren't getting passed. I tried this, and I seem to be fixed; http://ellislab.com/forums/viewthread/181888/#863106 Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); My Form validation - El Forum - 02-11-2012 [eluser]CroNiX[/eluser] One other thing: Code: $this->load->library('form_validation'); |