![]() |
[solved]Pass bidimensional array to dropdown form - 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: [solved]Pass bidimensional array to dropdown form (/showthread.php?tid=55282) |
[solved]Pass bidimensional array to dropdown form - El Forum - 10-18-2012 [eluser]Juan Velandia[/eluser] Hello Everyone, I have an array like this: Code: Array And I would like to show the [placa] on the dropdown, and pass the [id] on the post form. someting like : Code: <option value=[id]>[placa]</option> any ideas? thanks in advance! [solved]Pass bidimensional array to dropdown form - El Forum - 10-18-2012 [eluser]Juan Velandia[/eluser] Well I decide to change the nested array to a stdClass Object: Code: Array And use a for each Code: <select name="vehiculo"> that did the trick.. [solved]Pass bidimensional array to dropdown form - El Forum - 10-18-2012 [eluser]egy_programozo[/eluser] or create an array like this Code: $array = array( '' => 'Choose one...' Code: echo form_dropdown('placa', $array, ''); [solved]Pass bidimensional array to dropdown form - El Forum - 10-18-2012 [eluser]Juan Velandia[/eluser] Sure thing, Thats more the CI way.. Thanks a lot! [solved]Pass bidimensional array to dropdown form - El Forum - 10-18-2012 [eluser]Juan Velandia[/eluser] I change my model to: Code: foreach($query->result() as $row) to use: Code: echo form_dropdown('placas', $placas, ''); And worked like a charm! |