I'm trying to make database CRUD editing in CodeIgniter 4 with Modal (Bootstrap 5), but I always get this error : Can't find a route for 'post: ta'. This line of code work fine ( add a record ) :
$routes->post('tambah-TA', 'Admin\Ahli::tambah_TA');
but this one (update a record) :
$routes->post('update-TA/(:any)', 'Admin\Ahli::update_TA/$1');
always throw error Can't find a route for 'post: ta'. I have checked syntax and backslash. These are the functions for add record and update in Ahli.php (controller) :
public function tambah_TA()
{
$data = [
'nama' => $this->request->getPost('nama'),
'alamat' => $this->request->getPost('alamat'),
'no_ktp' => $this->request->getPost('no_ktp'),
'sipp' => $this->request->getPost('sipp'),
'sipp_ed' => $this->request->getPost('sipp_ed'),
'str' => $this->request->getPost('sipp'),
'str_ed' => $this->request->getPost('sipp_ed'),
'kategori' => $this->request->getPost('kategori'),
'perusahaan' => $this->request->getPost('perusahaan'),
'kota' => $this->request->getPost('kota'),
'posisi' => $this->request->getPost('kota'),
'ijazahS1' => $this->request->getPost('ijazahS1'),
's1_univ' => $this->request->getPost('s1_univ'),
's1_thn' => $this->request->getPost('s1_thn'),
'ijazahS2' => $this->request->getPost('ijazahS2'),
's2_univ' => $this->request->getPost('s2_univ'),
's2_thn' => $this->request->getPost('s2_thn'),
'ijazahS3' => $this->request->getPost('ijazahS3'),
's3_univ' => $this->request->getPost('s3_univ'),
's3_thn' => $this->request->getPost('s3_thn')
];
// dd($data);
//$ta = $this->taModel = new TAModel();
$success = $this->TAModel->tambahTA($data);
if ($success) {
return redirect()->back()->with('success', 'Data berhasil ditambah');
}
}
public function update_TA($id) {
$data = [
'nama' => $this->request->getPost('nama'),
'alamat' => $this->request->getPost('alamat'),
'no_ktp' => $this->request->getPost('no_ktp'),
'sipp' => $this->request->getPost('sipp'),
'sipp_ed' => $this->request->getPost('sipp_ed'),
];
$success = $this->TAModel->update($id, $data);
if ($success) {
return redirect()->back()->with('success', 'Data berhasil di-update');
}
}
Can anybody give me a clue ?