CodeIgniter Forums
Associating a Controller Function with a Rule Group - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Associating a Controller Function with a Rule Group (/showthread.php?tid=24305)



Associating a Controller Function with a Rule Group - El Forum - 11-05-2009

[eluser]Unknown[/eluser]
Hello

Let me begin by saying that I've just started using CodeIgniter and I think it's great.
I really enjoy using the form_validation class and I think that the ability to associate a controller function with a validation rule group is awesome.
I've used this feature and everything worked out great until I've tried to associate a controller function that takes paramenters with a rule group.
For example:
Code:
class Test extends Controller{
  function thisFunction(){
     $this->form_validation->run();
  }
}
fires the "test/thisFunction" rule group as expected.
But
Code:
class Test extends Controller{
  function thisFunction($paramA,$paramB){
    $this->form_validation->run();
  }
}
doesn't trigger the validation. I've also noticed that if you name the rule group like 'controller/function/firstValue/secondValue' the validation will run if the function is called with those exact values as parameters.
I am aware that I can simply name the validation group and just call $this->form_validation->run('groupName'), and that's actually what I've ended up doing, but I'm just wondering if there is a proper way to associate a controller function that takes parameters with a rule group.
Thank you.