[eluser]arjo[/eluser]
I want to fill a dropdown selectbox using ignited record but I get the following error:
Message: Object of class IR_record could not be converted to string
Here is my code:
Code:
//controller
$this->load->model('MDocumenttypes','documenttypes');
$data['documenttype'] = $this->documenttypes->getDropDown();
$this->load->vars($data);
//model
function getDropDown() {
$this->select('documenttype_ID, name');
$recs = $this->find_all();
return $recs;
}
//view
<p><label for='documenttype'>Documenttype</label><br />
<?=form_dropdown('documenttype_ID',$documenttypes,$document->documenttype_ID);?>
</p>
I tried to convert the object to an array but I got stuck here:
Code:
function getDropDown() {
$this->select('documenttype_ID, name');
$recs = $this->find_all();
$data = $recs->get_data();
//debuggin loop to show content of array
foreach($data as $column => $value)
{
echo "$column => $value\n";
}
exit;
return $data;
}
Unfortunately get_data() only works if you populate $recs using $this->get().
And this returns just 1 record
If I loop through the array using the find_all() method (like above) it returns the following error:
Fatal error: Call to a member function get_data() on a non-object
Does anyone know how what I should do (beside going to the beach bc the weather is too good to do stuff like this now
greetz Arjo