CodeIgniter Forums
Associating a Controller Function with a Rule Group Doesn't Work With Parameter - 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 Doesn't Work With Parameter (/showthread.php?tid=37493)



Associating a Controller Function with a Rule Group Doesn't Work With Parameter - El Forum - 01-11-2011

[eluser]tommo.wilson[/eluser]
In the form validation guide there is a topic on Associating a Controller Function with a Rule Group

This works perfectly when the function doesn't have a parameter. But once you introduce the parameter it stops working.

ie: This url http://www.example.com/newpage/index calls the newpage controller and index function. The form validation rules (in the config/form_validation.php file) for this are below.

Code:
'newpage/index' => array(
                                    array(
                                            'field' => 'title',
                                            'label' => 'title',
                                            'rules' => 'trim|required|alpha_numeric_space|callback_title_exists|max_length[50]'
                                         ),
                                    array(
                                            'field' => 'content',
                                            'label' => 'content',
                                            'rules' => 'trim'
                                         ) ..... etc.

This url http://www.example.com/editpage/index/30 calls the editpage controller and index function with a parameter of 30. The form validation rules (in the config/form_validation.php file) for this are below.

Code:
'editpage/index' => array(
                                    array(
                                            'field' => 'title',
                                            'label' => 'title',
                                            'rules' => 'trim|required|alpha_numeric_space|callback_title_exists|max_length[50]'
                                         ),
                                    array(
                                            'field' => 'content',
                                            'label' => 'content',
                                            'rules' => 'trim'
                                         ) ..... etc.

This second case doesn't work. I assume it is because editpage/index doesn't match up with editpage/index/30.

Does anyone know what the problem is?

Cheers
Tom


Associating a Controller Function with a Rule Group Doesn't Work With Parameter - El Forum - 01-11-2011

[eluser]Cristian Gilè[/eluser]
Hi Tom,

http://ellislab.com/forums/viewthread/104425/

Cristian Gilè


Associating a Controller Function with a Rule Group Doesn't Work With Parameter - El Forum - 01-11-2011

[eluser]tommo.wilson[/eluser]
Thanks dude...

That change hasn't been incorporated into the code yet but I've just copied it into mine.