Hello, I have problem with editing values in my database.
I have 3 tables, 'tbl_perawat', 'tbl_ruangan', and 'perawatruangan'.
'tbl_perawat' structure: http://prntscr.com/8xckn2
'tbl_ruangan' structure: http://prntscr.com/8xckyl
'perawatruangan' structure: http://prntscr.com/8xcl3v and relation: http://prntscr.com/8xcl85
Here's my controller for 'perawatruangan':
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class PerawatRuangan extends CI_Controller { function __construct() { parent::__construct(); /* Standard Libraries of codeigniter are required */ $this->load->database(); $this->load->helper('url'); /* ------------------ */ $this->load->library('grocery_CRUD'); } public function index() { //Inisialisasi $crud = new grocery_CRUD(); $crud->set_subject('Perawat Ruangan'); $crud->set_table('tbl_ruangan'); $crud->set_theme('datatables'); //Label Fields $crud->display_as('kdRuangan','Kode Ruangan'); $crud->display_as('namaRuangan','Nama Ruangan'); $crud->display_as('detail','Perawat'); $crud->columns('kdRuangan','detail'); $crud->fields('kdRuangan','detail'); $crud->unset_add(); $crud->unset_delete(); //Kolom Input dan Callbacks $crud->set_relation_n_n('detail', 'perawatruangan', 'tbl_perawat', 'kdRuangan', 'idPerawat', 'namaPerawat','prioritas'); //Aturan Pengisian Form $crud->set_language('indonesian'); //Cetak Tabel $output = $crud->render(); $this->_example_output($output); } function _example_output($output = null) { $this->load->view('vperawatruangan.php',$output); } }
When I try to edit, adding or deleting namaPerawat, I can't update. But when I click first 'Remove All' before I try to adding or deleting, it works. Any solution how to add/delete without click 'Remove All' first?
If I add other values, it replace old values with the new ones in database, but it has error noticed in edit form.
=================================================
Problem solved.