CodeIgniter Forums
Two Forms in One Controller? - 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: Two Forms in One Controller? (/showthread.php?tid=34180)



Two Forms in One Controller? - El Forum - 09-21-2010

[eluser]ShoeLace1291[/eluser]
I'm building a members admin page. On the index controller, there's a form that let's you search for members by name. Then on the same controller, database results are queried by the last 5 members to join which creates a form for delete checkboxes. Since there are two forms in the same controller, I've run into a problem with the form_validation->run() function. How do I tell it which form is being executed?


Two Forms in One Controller? - El Forum - 09-21-2010

[eluser]mi6crazyheart[/eluser]
I think u'll face problem only when u'll try to do both the things in one function(of controller) else, if u use 2 different controller function for 2 different things(as u've mentioned) then i don't think u'll get any problem...


Two Forms in One Controller? - El Forum - 09-22-2010

[eluser]natefons[/eluser]
why not save your self the headache, and do the forms outside the controller?

in the view:
Code:
<form name="formA" method="post" action="/index.php/controller/func1">
blha blah blah
</form>

<form name="formB" method="post" action="/index.php/controller/func2">
blah blah blah
</form>


now in the controller, you would create 2 functions that handles the 2 forms separately.

u can use the $this->input->post to get the post details.