My Form validation |
[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
[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]');
[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.
[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.
[eluser]InsiteFX[/eluser]
it should be saved as ./application/libraries/MY_Form_validation.php
[eluser]moth[/eluser]
It is. I have; /application/config/form_validation.php (as described here: http://ellislab.com/codeigniter/user-gui...ngtoconfig) ..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(
[eluser]moth[/eluser]
MY_Form_validation Loads - I see my debug message, I just don't get any validation...
[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');
[eluser]CroNiX[/eluser]
One other thing: Code: $this->load->library('form_validation'); |
Welcome Guest, Not a member yet? Register Sign In |