[eluser]developer10[/eluser]
[quote author="max123" date="1261575441"]I'm ok untill step3, but how can I add items to drop down box according to the CI frame work. I know the normal way. I need to know how to do it using frame work[/quote]
i had the same problem recently and some very kind users of this forum helped me.
let's start. model:
Code:
function getdropdown_djelatnosti_array($key, $value, $from)
{
$result = array();
$array_keys_values = $this->db->query(' SELECT '.$key.', '.$value.' FROM '.$from.' ORDER BY djelatnost ASC ');
$result['Sve'] = '-- Odaberi djelatnost --'; // i added this line because i need some default value (in case user doesnt select anything from this box). it of course displays on the top of all rows in the drop-down
foreach ($array_keys_values->result() as $row)
{
$result[$row->$key] = $row->$value;
}
return $result;
}
my view in which the drop-down box is displayed:
Code:
echo form_open('prikazi/pretraga', $frmSrc_atts);?>
<div class='stavka'>
<label>Djelatnost</label>
<?php echo form_dropdown('djelatnost', $dropdown_djelatnosti, 'Sve'); ?> // Note the 3rd parameter here ('Sve'). thats the default value for the drop-down, if nothing is selected from the box before submitting the form.
</div>
hope this helps!