简体   繁体   中英

grocery crud : field type dropdown with custom array data

Message: Undefined index: nm_pemohon

whats wrong in my controller script

$this->load->model('pemohon_model');
$data_pemohon = $this->pemohon_model->ambil_nama_pemohon();
$crud->field_type('id_pemohon','dropdown', array($data_pemohon['id_pemohon'] = $data_pemohon['nm_pemohon']));

and i have this script in my model

function ambil_nama_pemohon()
    {
        $session_data = $this->session->userdata('logged_in');
        $this->db->select('id_pemohon, nm_pemohon');
        $this->db->where('insert_by ='.$session_data['id_user']);
        $this->db->order_by('id_pemohon','asc');
        $query = $this->db->get('tbl_pemohon');
        if ($query->num_rows() > 0)
        {
            $data_pemohon = array();
            foreach ($query->result_array() as $row)
            {
                $data_pemohon[$row['id_pemohon']] = $row['nm_pemohon']; 
            }
        }
        $query->free_result();
        return $data_pemohon;       
    }

please fix my script.

sorry for my english

The function ambil_nama_pemohon() return an array

you just use this in the 3 argument of field type

$crud->field_type('id_pemohon','dropdown', $data_pemohon);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM