Welcome Guest, Not a member yet? Register   Sign In
fill dropdown using ignited record
#1

[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 />
&lt;?=form_dropdown('documenttype_ID',$documenttypes,$document->documenttype_ID);?&gt;
</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 Sad

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 Wink

greetz Arjo


Messages In This Thread
fill dropdown using ignited record - by El Forum - 06-24-2009, 05:46 AM
fill dropdown using ignited record - by El Forum - 06-24-2009, 09:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB