form_dropdown() Selected value - 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: form_dropdown() Selected value (/showthread.php?tid=17142) |
form_dropdown() Selected value - El Forum - 03-26-2009 [eluser]mdcode[/eluser] I have a form with a few select boxes pulling options from the database. Basically when the for is loaded, I want these select boxes to be blank, however they are always populated with the result for id equal to 1. How can I get them to display blank without having blank rows in my db? VIEW: Seemingly the selected attribute on the form_dropdown() function in the view doesn't do anything... I have tried it with nothing: Code: <?php echo form_dropdown('customer', $customers, '', $dds); ?> Code: <?php echo form_dropdown('customer', $customers, ' ', $dds); ?> Code: <?php echo form_dropdown('customer', $customers, '2', $dds); ?> Code: <?php echo form_dropdown('customer', $customers, 'Customer One', $dds); ?> CONTROLLER: Code: /* grab the customer list */ MODEL: Code: /* get all customers */ form_dropdown() Selected value - El Forum - 03-26-2009 [eluser]pistolPete[/eluser] Could't you add a blank entry to your dropdown when you generate the array? Code: $data = array(); form_dropdown() Selected value - El Forum - 03-26-2009 [eluser]mdcode[/eluser] Unfortunately not -- while your code doesn't generate any errors, it also does nothing to the results of the form even though id 0 is not being used. Following on your advice I have also tried to formulate it the same as the rest of the query: Code: $data['customers'][$value['0'] = $value['']; Code: A PHP Error was encountered Code: $data['customers'][0] = $value['']; Code: A PHP Error was encountered form_dropdown() Selected value - El Forum - 03-26-2009 [eluser]mdcode[/eluser] Ok, playing around with this and with ideas running through my head using your code I have got it to work like this: Code: /* grab the division list */ |