[eluser]w3ttr3y[/eluser]
I apologize as this is a rather basic question, but I've been struggling with it for awhile. I had form validation working, but as I read more I really liked the idea of moving validation to the configuration file.
First of all, let me make sure my long term goal is possible. Can I use the groups with an autoloaded configuration file? (I wouldn't see why not, but as I'm having problems I figured I should ask)
Since that was failing and some log messages I added indicated it was due to a lack of rules, I decided to try explicitly passing the rules array to the validation library.
If I explicitly set the rules, and then do an empty run it works as expected.
Code:
$this->form_validation->set_rules($rules['register']);
if($this->form_validation->run() === FALSE ) {...
According to the user guide, I can pass the name to the run method, so I thought I should be able to do the following...
Code:
$this->form_validation->set_rules($rules);
if($this->form_validation->run("register") === FALSE ) {...
I can't get that to work, however. Is there a difference in the configuration array between the two methods that I didn't pick up on?
I really appreciate any guidance!
Edit October 8, 2010: After looking at the code, it looks like if you set rules with the set_rules function you can't use groups. That's fine, I was just trying trouble shoot why the rules weren't automatically loading so I'll just revert to my original problem.
Second edit October 8, 2010: After debugging some more, I've figured out that in that the config file is loaded but that the $this->_config_rules variable never gets set so it never finds the rules.
Edit October 10, 2010: Solved. I was sub-classing Form_Validation (i.e. My_Form_validation) and in the constructor I wasn't accepting a rules argument. So of course it worked initially (with setrules) but not when I passed them through the constructors. For some reason, I needed to add the rules parameter in order to get the rules from the config file to work (I haven't dug into why, but when I fixed it they started working.
Thanks,
Bill