Form_Validation Config file not working |
[eluser]thors1982[/eluser]
I have been trying to move my form validation to a config file like in the user guide (here) and it took me hours to figure out its not working because I was setting the delimiters like this Code: $this->set_error_delimiters('<span class="Warning">', '</span>'); In a MY_Form_validation.php (library file). Is there a way to get both... set a global error_delimiter and use the config validation file?
[eluser]Rob Gordijn[/eluser]
I'm currently using a MY form validation, the config file with the 'rules' and a 'real' config file (look that one up in the manual) with delemiter_start and delemiter_end. My app is loading and using that config, and I set the formvalidation delemiters with those values. hope u understand, cheers
[eluser]thors1982[/eluser]
Not sure I fully understand... but I got it working by doing this Code: class MY_Form_validation extends CI_Form_validation Hopefully nothing is wrong with that method.... I do have another question though. Is it possible to call two $config rule groups? So I could put email on its own group, so I could use it seperatly. But if i wanted to use the email validation on the signup page as well, i could call both groups signup and email.
[eluser]Rob Gordijn[/eluser]
yes, that looks good. you can improve somewhat: Code: function __construct($config = array()) instead of setting $rules manually. and yes, I think you can run multiple rules/group's simultaneous if($this->form_validation->run('account/login') === TRUE){ // do shizzle with post vars } if($this->form_validation->run('account/other') === TRUE){ // do other shizzle with post vars } have fun!
[eluser]Esger[/eluser]
I had a problem (auto)loading the form validation rules from a file (application/config/form_validation.php) as well. The $config variable was reported not being defined, until I set the rules like this: $this->form_validation->set_rules($this->config->config); And I had to add 'form_validation' to the config files section of the autoload.php file.
[eluser]LairdWirli[/eluser]
I have the same problem: Message: Undefined variable: config after I moved the validation rules to (application/config/form_validation.php). I am happy that you found a work around. It doesn't work in my case and I assume there has to be a different/official solution to the problem, since it is described in the official user guide. |
Welcome Guest, Not a member yet? Register Sign In |