I'm trying to get a form populated by data coming from a Datamapper object.
Here's my controller code:
function find()
{
$sub_list = new Subject();
$data['s'] = $sub_list->all;
$this->load->view('professors/find', $data);
}
In my view I'd want to show a dropdown form with the data coming from that object but I can't make it work.
This code:
<?php echo form_dropdown('accesso', $s);?>
Just show me "Subject" for every field in the db.
Many thanks for the help! I'm sorry for the silly issue!
EDIT: Problem solved!
<?php foreach ($s as $a):?>
<?php $options[$a->name] = $a->name; ?>
<?php endforeach ?>
<?php echo form_dropdown('accesso', $options);?>
Thanks!
No comments:
Post a Comment