The updated data still doesn't change. The possibility for an error is in the ubahTypeBarang function. I have tried to find a solution, but still can't update the changed data
This models
public function ubahTypeBarang ()
{
$data = [
"barang_kode"=> $this->input->post('barang_kode', true),
"type_id"=> $this->input->post('type_id', true),
"barang_nama"=> $this->input->post('barang_nama', true),
];
$this->db->where('barang_id', $this->input->post('barang_id'));
$this->db->update('barang', $data);
}
This view
<div class="form-row">
<div class="form-group col-md-2">
<label for="kode">Kode</label>
<input type="text" name="barang_kode" class="form-control text-uppercase" id="barang_kode" value="<?= $barang["barang_kode"]; ?>">
<small class="form-text text-danger"><?= form_error('kode') ?></small>
</div>
<div class="form-group col-md-4">
<label for="type">Type</label>
<select class="form-control" id="type_id" name="type_id">
<?php foreach($type as $types) : ?>
<?php if( $types->type_id == $barang['type_id']) : ?>
<option value="<?php echo $types->type_id ?>" selected><?php echo $types->type_nama ?></option>
<?php else : ?>
<option value="<?php echo $types->type_id ?>"><?php echo $types->type_nama ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<small class="form-text text-danger"><?= form_error('type') ?></small>
</div>
<div class="form-group col-md-6">
<label for="nama">Nama Barang</label>
<input type="text" name="barang_nama" class="form-control text-capitalize" id="barang_nama" value="<?= $barang["barang_nama"]; ?>">
<small class="form-text text-danger"><?= form_error('nama') ?></small>
</div>
</div>
<button type="submit" name="tambah" class="btn btn-primary float-right">Tambah Data</button>