[eluser]laytone[/eluser]
[quote author="Bionicjoe" date="1266378005"]Ok. I think I'm closer with this, but no matter what I try I get an undefined variable error on my view page.
Controller
Code:
function addticket()
{
$this->template->set('title', 'Add ticket');
$this->template->set('heading', 'Add Ticket');
$this->load->model('outage_model');
$data['row'] = $this->outage_model->sitedropdown();
$this->template->load('template', 'addticket_view');
}
Model
Code:
public function sitedropdown()
{
// $q = $this->db->get('location');
// return $q->result_array();
$query = $this->db->get('location')->result_array();
$result = array();
foreach($query as $q)
$result[$q['locationid']] = $q['sitename'];
return $result;
}
View
Code:
echo form_open('outage/submit_addticket');
...
<tr><td>Location</td><td><?php echo form_dropdown($data); ?></td><tr>
I made a typo earlier and got several repeating index errors on the page, so I'm confident I'm getting an array to the page.[/quote]
You have to send the array of dropdown options to your view.
Controller
Code:
function addticket()
{
$this->template->set('title', 'Add ticket');
$this->template->set('heading', 'Add Ticket');
$this->load->model('outage_model');
$this->template->set('dropdownoptions', $this->outage_model->sitedropdown());
$this->template->load('template', 'addticket_view');
}
Then in your view you have a variable called $dropdownoptions that you send to the form_dropdown() function.