![]() |
Form Validation Rule Groups errors... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Form Validation Rule Groups errors... (/showthread.php?tid=41778) |
Form Validation Rule Groups errors... - El Forum - 05-16-2011 [eluser]tjtyrrell[/eluser] Please forgive me in advance if I am just missing something. I have no clue what is going wrong. So I want to have 2 rule groups on a specific page and one or the other will be called based on user input. In my controller I first declare and set the rules Code: $config = array( Then I try to call one of the groups: Code: $this->form_validation->run('valid'); I've found that the code breaks without warning if you have faulty "rules", but I've tested my rules by creating a $config array without the rule groups and they work (any typos in here are because of trying to edit it in a textarea). (non-rule grouped $config array) Code: $config = array( So: When setting the rules in an array without declaring "groups" my rules work and the echo validation_errors(); call works when calling the "run" method. However, when creating validation rule groups I am having issues. I am trying to follow the user guide but have been racking my brain for hours trying to figure this out on my own, and now need help. Also, when var_dumping $errors = validation_errors(); I get an empty string... and when if-else testing on the run sequences, the forms do not pass under any circumstances. Please note: 1) When trying to call the form_validation run() command with rules I use the rule group name I've created (e.g. $this->form_validation->run('valid'); ) 2) Thinking that there might be some name conflicts I renamed the groups to random names and they are still not working 3) Currently I am only making 1 rule, I used to have about 8, but with this issue I reduced it to 1 to try and minimize user-errors. I hope I've divulged enough information. I'm assuming it's just something small that I am completely overlooking. Thank you in advance for any and all help! Form Validation Rule Groups errors... - El Forum - 05-17-2011 [eluser]toopay[/eluser] To use group rules, you didnt need to declare it on your controller but simply create a file named form_validation.php in your 'application/config/' folder. In that file you will place an array named $config with your rules, like above. Form Validation Rule Groups errors... - El Forum - 05-17-2011 [eluser]tjtyrrell[/eluser] Bah! So the only way to get array groups to work is using the external config file? I'm trying to have 2 rule-sets for this one page, I have other pages that have a singular rule-set (for example, I have a user signup page). I was hoping that I could have a group of rule-sets for just this page using this method. I guess not, thanks for pointing out what I suppose should have been obvious - now that I checked the user guide again to see where it states that this option is only for the form_validation.php config file I see that this is "under" the "Saving Sets of Validation Rules to a Config File". Thus the intention that it's only usable this way. Thanks again - sorry for the newb post, TJ Form Validation Rule Groups errors... - El Forum - 05-17-2011 [eluser]InsiteFX[/eluser] Code: private $validation_rules = array(); InsiteFX |