Recieving form data - 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: Recieving form data (/showthread.php?tid=25287) |
Recieving form data - El Forum - 12-07-2009 [eluser]Random dude[/eluser] Hello, I just started using CodeIgniter and I'm very happy. I'm going to be using on http://ducatiadelaide.com.au for the new cms. In MVC its, class > function > data - not understanding this, I made my first controller <b>have a function that accepts form data</b> <code> class Do_Everything extends Controller //etc function show_something() { //load a view } function edit_something() { //receive form data //load a model, edit db } </code> The target of the form I tried to use was "domain/index.php/do_everything/edit_something However, I've found functions can't be called when sending POST data. Is this approach completely incorrect? Do you need a <b>separate controller to receive <i>each</i> form?</b> Right now I'm going to create a separate controller to accept the form data and call the model from there. What is the standard approach to accepting forms in CodeIgniter? Recieving form data - El Forum - 12-07-2009 [eluser]The Casual Bot[/eluser] MVC = model view controller you should be loading a view from your controller which contains the form then in you controller have a function to take the data ie Code: <?php and your form action should be "formaction" Recieving form data - El Forum - 12-07-2009 [eluser]Random dude[/eluser] Ahh, so after you load a view, the controller is still 'active' so to speak. So to have a <b>function</b> of a controller handle a form, you need to have the action as the name of the controller thats currently active? I've just noticed you have $this->load-><b>model</b>('viewfile'); - is model supposed to be view in this case? Thank you very much for your help. Recieving form data - El Forum - 12-07-2009 [eluser]The Casual Bot[/eluser] lol yeah it should say view my fault for copy and pasting you kinda got the idea when a controller is loaded ie: www.sitename.com/imdex.php/Do_Everything the index function is load automatically but when you submit your form it will change the url to www.sitename.com/imdex.php/Do_Everything/formaction this then will access you formaction function so a controller can handle multiple forms and actions hope this helps |