![]() |
How to access values returned from view form - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: How to access values returned from view form (/showthread.php?tid=20529) |
How to access values returned from view form - El Forum - 07-13-2009 [eluser]TWP Marketing[/eluser] I'm stuck on a point using the cart library. The userguide (SVN) page gives an example of how to pass the 'rowid' and 'qty' values from the view form to the controller/model. Code: <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?> This is accessed using $this->input->post () and I can see the posted values using profiler, for example Code: _POST[1] array( [rowid] => 7c9d5fbcdc5ae18a05e0b792cfccafbf, [qty] => 1); Noting the array keys "[rowid]" and "[qty]" do _NOT_ fit the proper expression for array indexes (I think), How do I reference these posted values? I've tried the following, which fail to return anything, (empty string), or produce a php warning of incorrect usage of index: Code: $rowid = $this->input->post ($i.'[rowid]'); Thanks Dave How to access values returned from view form - El Forum - 07-13-2009 [eluser]Colin Williams[/eluser] You have to understand your array. Each value in post is an array. There is a $_POST[0]['rowid'] but there is no $_POST[0[rowid]] and that is why your methodology is failing. It would be more appropriate to do: Code: $rowid = $this->input->post("[$i][rowid]"); How to access values returned from view form - El Forum - 07-14-2009 [eluser]TWP Marketing[/eluser] Thanks for the reply, I solved the problem using Code: $item = $this->input->post($i); Code: $rowid = $item['rowid']; I missed fact that the form was returning an array (not enough/too much coffee?). Dave |