Too few arguments to function Admin::edit(), Too few arguments to function Admin::edit(), codeigniter codeigniter

Too few arguments to function Admin::edit(),


Let me explain to you.

Edit function needs one parameter (i.e. id). In your form, you are submitting the form without id.

You just need to add the id at the end of the URL like below. Suppose id is 2 then you have to add 2.

base_url('admin/edit/2')<form action="<?= base_url('admin/edit/2');?>" method="post">


You are only passing $id in

$this->usermodel->Role_model($get['id']);


You have to change your function if you want to post value in hidden input. Oner more thing you have to use default argument if you are not sure about the data is present or not. Always check step by step that data is present or not than do anything.

Write echo here so you get the value in hidden field

<input type="hidden" name="id" value="<?php echo $user_role['id']; ?>">

After that change in the function:

public function edit(){    $id = $this->input->post('id');    $data['title'] = 'Role';    $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();    if(!empty($id)):        $data['user_role'] = $this->Role_model->GetId($id);    else:        //some error message     endif;    $this->form_validation->set_rules('role', 'Role', 'required');    if ($this->form_validation->run() == false) {        $this->load->view('templates/header', $data);        $this->load->view('templates/sidebar', $data);        $this->load->view('templates/topbar', $data);        $this->load->view('admin/edit', $data);        $this->load->view('templates/footer');    } else {        $this->Role_model->EditRole();        $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Role Edited!</div>');        redirect('admin/role');    } }