Welcome Guest, Not a member yet? Register   Sign In
[CI2] Missing argument 1 for Daftarmobil::edit()

(This post was last modified: 03-28-2016, 02:07 AM by ciadmin.)

I got a problem with my code

here's the sourcecode :

controller : 
public function edit($id) {
$this->form_validation->set_rules('id_mobil', 'ID Mobil', 'required');
$this->form_validation->set_rules('merek', 'Merk Mobil', 'required');
$this->form_validation->set_rules('warna', 'Warna Mobil', 'required');
$this->form_validation->set_rules('nopol', 'No Polisi Mobil', 'required');
$this->form_validation->set_rules('tahun', 'Tahun Mobil', 'required');
$this->form_validation->set_rules('harga_dalamkota', 'Harga Dalam Kota', 'required');
$this->form_validation->set_rules('harga_luarkota', 'Harga Luar Kota', 'required');
if ($this->form_validation->run() === FALSE) {
$data['daftarmobil'] = $this->daftarmobil_model->detail_mobil();
$data['detail'] = $this->daftarmobil_model->detail_mobil($id);
$data=array('title' => 'Mengubah data mobil: '.$data['detail'],
'daftarmobil' => $this->daftarmobil_model->detail_mobil(),
'detail' => $this->daftarmobil_model->detail_mobil($id),
'isi'   =>'admin/daftarmobil/edit_mobil'
// Kalau tidak ada error berita diupdate
$data = array(

public function edit_mobil($data) {
$this->db->where('id_mobil', $data['id_mobil']);
return $this->db->update('data_mobil', $data);

<div class="konten">
<h1>Mengubah Data Mobil</h1>
<form name="form1" method="post" action="<?php echo base_url(); ?>admin/daftarmobil/edit" class="myform">
 <p><label for="id_mobil">ID Mobil</label>
   <input name="id_mobil" type="text" id="id_mobil" size="70" value="<?php echo $detail['id_mobil'] ?>">
   <label for="merek">Merk Mobil</label>
   <input name="merek" type="text" id="merek" size="70" value="<?php echo $detail['merek'] ?>">
   <label for="warna">Warna Mobil</label>
   <input name="warna" type="text" id="warna" size="70" value="<?php echo $detail['warna'] ?>">
   <label for="nopol">No Polisi Mobil</label>
   <input name="nopol" type="text" id="nopol" size="70" value="<?php echo $detail['nopol'] ?>">
   <label for="tahun">Tahun Mobil</label>
   <input name="tahun" type="text" id="tahun" size="70" value="<?php echo $detail['tahun'] ?>">
   <label for="harga_dalamkota">Harga Dalam Kota</label>
   <input name="harga_dalamkota" type="text" id="harga_dalamkota" size="70" value="<?php echo $detail['harga_dalamkota'] ?>">
   <label for="harga_luarkota">Harga Luar Kota</label>
   <input name="harga_luarkota" type="text" id="harga_luarkota" size="70" value="<?php echo $detail['harga_luarkota'] ?>">
   <input type="submit" name="submit" id="submit" value="Submit">
   <input type="reset" name="submit2" id="submit2" value="Reset">

i succeed change the data in the database, but when i submit the changes in the edit form it didnt redirect to : redirect(base_url().'admin/daftarmobil/');
and there's an error : Missing argument 1 for Daftarmobil::edit()

Help me please, thanks Smile


public function edit($id) <--- have you tried removing the $id param ?

<form name="form1" method="post" action="<?php echo base_url(); ?>admin/daftarmobil/edit/{mobile_id}" class="myform">. Tambah mobile id yang mahu di edit.
Keep calm.

PHP Code:
<form name="form1" method="post" action="<?php echo base_url(); ?>admin/daftarmobil/edit/{mobile_id}" class="myform">. Tambah mobile id yang mahu di edit.

Should be:

form name="form1" method="post" action="<?php echo base_url('admin/daftarmobil/edit/{mobile_id}'); ?>" class="myform">. Tambah mobile id yang mahu di edit

Also where are you passing the mobile_id from?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

(This post was last modified: 03-28-2016, 09:21 AM by arma7x. Edit Reason: Typo )

Maybe he pass via uri_segment & anchor link to edit mobile data. Something like anchor('admin/daftarmobil/edit/{id}'). In my assumption daftarmobil controller got index,edit,delete,insert.
Keep calm.

Theme © iAndrew 2016 - Forum software by © MyBB