Passing an array through GET while using url_to_assoc - 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: Passing an array through GET while using url_to_assoc (/showthread.php?tid=53740) |
Passing an array through GET while using url_to_assoc - El Forum - 08-07-2012 [eluser]jhyland[/eluser] Currently, on the website I have now (which will be replaced with the new CI site), there are multi selects and check boxes. So if someone selects two check boxes, or two options in a multi select, the URL looks like this.. http://website.com/?checkbox[]=var1&checkbox;[]=var2&multi;[]=var1&multi;[]=var2 (Ignore the ';', the forum keeps putting those in there.) That will get processed as this: array( checkbox => array('var1','var2'), multi => array('var1','var2') ); I want to use the $this->uri->uri_to_assoc option in CI, but that only does a single level associative array. How can I accomplish the same task, using the url_to_assoc? Also, how do I have a CI form "action" go to that type of url? Meaning, instead of it going to ?this=that, how do I make it go to /this/that/ ? Thanks! Passing an array through GET while using url_to_assoc - El Forum - 08-07-2012 [eluser]InsiteFX[/eluser] json encode and json decode Passing an array through GET while using url_to_assoc - El Forum - 08-07-2012 [eluser]jhyland[/eluser] How do I have the form post the json code to a URL? And how does CI interpret /something/like/this/ as json? Passing an array through GET while using url_to_assoc - El Forum - 08-07-2012 [eluser]InsiteFX[/eluser] You need to use javascript. jQuery - Read up Ajax Passing an array through GET while using url_to_assoc - El Forum - 08-09-2012 [eluser]jhyland[/eluser] You just gave a link to the jquery site... Can you help me out with maybe something more specific? Passing an array through GET while using url_to_assoc - El Forum - 08-09-2012 [eluser]PhilTem[/eluser] Just make your forms submit GET data and no POST data. Code: echo form_open($action, array('method' => 'GET')); Voila Passing an array through GET while using url_to_assoc - El Forum - 08-09-2012 [eluser]jhyland[/eluser] Except, the point is to get rid of the ugly url: http://website.com/?checkbox[]=var1&checkbox;[]=var2&multi;[]=var1&multi;[]=var2 Passing an array through GET while using url_to_assoc - El Forum - 08-09-2012 [eluser]jhyland[/eluser] This works. I modified the URI.php file. Code: function _uri_to_assoc($n = 3, $default = array(), $which = 'segment') The request: http://localhost/index.php/ci/view_assets/foo/a/bar/b/foo/c/bar/d/test/true Returns: Quote:Array Hope this helps other people Passing an array through GET while using url_to_assoc - El Forum - 08-10-2012 [eluser]jhyland[/eluser] This would also entail editing the assoc_to_uri function for redirecting to the uri. Code: function assoc_to_uri($array) Passing an array through GET while using url_to_assoc - El Forum - 08-19-2012 [eluser]jhyland[/eluser] http://www.linuxdigest.org/2012/08/codeigniter-uri-associative-array-parsing/ There ya go |