[CI2] Missing argument 1 for Daftarmobil::edit() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [CI2] Missing argument 1 for Daftarmobil::edit() (/showthread.php?tid=64801) |
[CI2] Missing argument 1 for Daftarmobil::edit() - vallerypw - 03-28-2016 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' ); $this->load->view('admin/layout/wrapper',$data); // Kalau tidak ada error berita diupdate }else{ $data = array( 'id_mobil'=>$this->input->post('id_mobil'), 'merek'=>$this->input->post('merek'), 'warna'=>$this->input->post('warna'), 'nopol'=>$this->input->post('nopol'), 'tahun'=>$this->input->post('tahun'), 'harga_dalamkota'=>$this->input->post('harga_dalamkota'), 'harga_luarkota'=>$this->input->post('harga_luarkota') ); $this->daftarmobil_model->edit_mobil($data); redirect(base_url().'admin/daftarmobil/'); } } model: public function edit_mobil($data) { $this->db->where('id_mobil', $data['id_mobil']); return $this->db->update('data_mobil', $data); } view: <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'] ?>"> </p> <p> <label for="merek">Merk Mobil</label> <input name="merek" type="text" id="merek" size="70" value="<?php echo $detail['merek'] ?>"> </p> <p> <label for="warna">Warna Mobil</label> <input name="warna" type="text" id="warna" size="70" value="<?php echo $detail['warna'] ?>"> </p> <p> <label for="nopol">No Polisi Mobil</label> <input name="nopol" type="text" id="nopol" size="70" value="<?php echo $detail['nopol'] ?>"> </p> <p> <label for="tahun">Tahun Mobil</label> <input name="tahun" type="text" id="tahun" size="70" value="<?php echo $detail['tahun'] ?>"> </p> <p> <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'] ?>"> </p> <p> <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'] ?>"> </p> <p> <input type="submit" name="submit" id="submit" value="Submit"> <input type="reset" name="submit2" id="submit2" value="Reset"> </p> </form> </div> 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 RE: [CI2] Missing argument 1 for Daftarmobil::edit() - anangind - 03-28-2016 Hi, public function edit($id) <--- have you tried removing the $id param ? RE: [CI2] Missing argument 1 for Daftarmobil::edit() - arma7x - 03-28-2016 <form name="form1" method="post" action="<?php echo base_url(); ?>admin/daftarmobil/edit/{mobile_id}" class="myform">. Tambah mobile id yang mahu di edit. RE: [CI2] Missing argument 1 for Daftarmobil::edit() - InsiteFX - 03-28-2016 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. Also where are you passing the mobile_id from? RE: [CI2] Missing argument 1 for Daftarmobil::edit() - arma7x - 03-28-2016 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. |