title: Question about form_dropdown with Codeigniter
body: <p>I have a question about using <code>form_dropdown()</code>.  </p>
  
  <p><strong>The code below works,</strong>  but i am unsure about if I have to do the new array in the view or is there a better way of doing it with the array <code>$games</code> - passed from <code>$data['games']</code>?</p>
  
  <p>Should I be doing all the processing in the controller and sending over a ready array to populate the dropdown?   </p>
  
  <p>I tried this in the view: <code>echo form_dropdown('games', $games);</code>  but got the error "Object of class stdClass could not be converted to string", I think it's because its an array of objects and I have to convert it?</p>
  
  <p><strong>TABLE: GAMES</strong></p>
  
  <p>GM_ID - int</p>
  
  <p>GM_NAME - var</p>
  
  <p><strong>MODEL:</strong></p>
  
  <pre><code>class Test_model extends CI_Model {
  
    function __construct()
    {
      // Call the Model constructor
      parent::__construct();
    }
    function get_game_names() 
    {
      $queryg = $this-&gt;db-&gt;query("SELECT * FROM games");
      return $queryg-&gt;result();
    }
  }
  </code></pre>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>class Test extends CI_Controller {
  
    public function index()
    {
      $this-&gt;load-&gt;model('test_model');
      $data['games'] = $this-&gt;test_model-&gt;get_game_names();
      $this-&gt;load-&gt;view('view_test',$data);
     }
  
  }
  </code></pre>
  
  <p><strong>VIEW</strong></p>
  
  <pre><code>$this-&gt;load-&gt;helper('form');
  echo form_open('send');
  
  $list = array();  //is this the best way to do it??
  foreach($games as $row)
  {
    $list[$row-&gt;GM_ID] = $row-&gt;GM_NAME;    //is this the best way to do it??
  }
  
  echo form_dropdown('games', $list);  //then pass this array?
  echo form_close();
  </code></pre>