php - codeigniter form_dropdown, set option value without an array -


i want fetch table has 2 columns: id , name, , want column id value each option, , column name option name

this controller

 //populate provinsi          $this->load->model('provinsi');          $provinsi = $this->provinsi->get();            $this->load->view('admin/pages/product_form', array(              'provinces' => $provinsi,          ));

and in view

<?php  $options_provinsi = array('select_one' => 'select one');  foreach ($provinces $provinsi) {         $options_provinsi[] = array(                $provinsi->id => $provinsi->nama,         );  }    $extra = 'id="provinsi" class="form-control" onchange="loadlocation('provinsi','kota');"';  echo form_dropdown('provinsi', $options_provinsi, 'select_one', $extra);  ?>
code meet needs, because use array, dropdown become this:

dropdown_error

how set option value without using array?

replace foreach loop

foreach ($provinces $provinsi) {        $options_provinsi[$provinsi->id] = $provinsi->nama; } 

and in view

$extra = null; echo form_dropdown('provinsi', $options_provinsi, 'select_one', $extra); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -