![]() |
How to pass data from a one form to another - 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: How to pass data from a one form to another (/showthread.php?tid=60944) |
How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]Linkark07[/eluser] Hi there. Sorry if the title is a little confusing. Ok, here is my problem: I have a dropdown list with names of some courses from a table. The user should select one of them and then click submit. After that, another form appears with textboxes that must be populated with more information of the course the user selected, let's say, duration and cost. I have been thinking this since yesterday but nothing has come to my mind as to how solve this part. Anyone could guide me as to how obtain the name of the dropdown list, use it as a where for my select query and then with the results populate those textboxes. Thanks in advance! How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]CroNiX[/eluser] Code: class Some_controller extends CI_Controller { How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]Linkark07[/eluser] On the textbox form, if I use a static value on the model function everything works fine, and each textbox is populated. But if I try to pass the value from the dropdown then these messages appear: Message: Undefined variable: info Message: Missing argument 1 for Participante_model::obtenerdatosgrupo(), called in C:\xampp\htdocs\educcont\application\controllers\site.php on line 116 and defined Here is the code: Dropdown view Code: <?=form_open(base_url().'site/buscarcurso', $attributes)?> Controller Code: public function buscarcurso(){ Model Code: public function obtenerdatosgrupo($info){ How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]CroNiX[/eluser] You have a lot of unneeded stuff in there, try simplifying it to the basics. Code: public function buscarcurso(){ Code: public function obtenerdatosgrupo($nombre){ How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]Linkark07[/eluser] Found the last part of the issue: the function on controller for load the second form. Here is how I have it: Code: public function confirma_inscr(){ The message that appears when I try to load that page is: Message: Undefined variable: nombre How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]CroNiX[/eluser] Because of the way you assign it in the controller, in the view it would be $query['nombre'] When you pass an array to the view, it runs extract() on the array. How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]Linkark07[/eluser] Problem still persisted. But I found a solution to the problem. Dunno if it is right though, but the textboxes are populated on the second form. In buscarcurso I added this: Code: $this->session->set_flashdata('nombre', $nombre); And in confirma_inscr I added this: Code: $nombre = $this->session->flashdata('nombre'); Thanks for everything CroNiX How to pass data from a one form to another - El Forum - 08-06-2014 [eluser]CroNiX[/eluser] I'd urge you to try to find the problem and correct it. Using flashdata is not a good long term solution, especially with critical data, and you can run into problems with session. If you want further help repost all of the code, along with the view for the 2nd form. I missed where you were using $query->result(), and I told you how to do it with an array ($query->result_array()) instead of an object. So instead of $query[‘nombre’] it should have been $query->nombre in the view. How to pass data from a one form to another - El Forum - 08-07-2014 [eluser]Linkark07[/eluser] Was suspecting that wasn't the real solution. Found another way: At the end of buscarcurso I added this: Code: $this->confirma_inscr($nombre); The textboxes are populated on the second form. How to pass data from a one form to another - El Forum - 08-07-2014 [eluser]CroNiX[/eluser] Good deal ![]() |