I have a controller that calls my model to insert a new record, returned the id of the new record, and then does a redirect to display the new record. But I get an error: "The route for '/r/xx' cannot be found". My Routes.php has a route:
$routes->get("/r/(:num)", "Home::showRec/$1");
The controller code:
$rid = $mymodel->mSaveNew($data); ##return correct new id
if ($rid === false) {
$this->session->setFlashdata('errors', "?system error adding new record");
} else {
$this->session->setFlashdata('messages', "*** Added new record #$rid");
}
return redirect("/r/$rid"); ### this fails ###
What is wrong with my route?
The same redirect() route called in another controller method for updating an existing record works fine.
$rid
returned as expected? a number?$routes->get('/a', 'Home::addRec');
$routes->post('/a', 'Home::saveNewRec');
return redirect()->to("/r/$rid");
->to()
bit as well in CI4.