在我的 codeigniter4 应用程序中,我在路由上遇到了奇怪的问题,
在路由配置中,我有这样的组路由
$routes->group("admin", function($routes){
$routes->match(['get'],'dashboard','Dashboard::index',[
'as'=>'adm_dash'
]);
//start customer
$routes->get('customer/add','Customer::index',[
'as'=>'adm_cust_add_new'
]);
$routes->get('customer/view','Customer::view',[
'as'=>'adm_cust_view'
]);
$routes->get('customer/manage','Customer::manage',[
'as'=>'adm_cust_manage'
]);
//end customer
//start customer actions
$routes->post('customer/create','Customer::createcustomer',[
'as'=>'adm_cust_create_action'
]);
});
在视图文件中
<form class="m-t-20" method="post" action="<?= route_to('adm_cust_create_action') ?>">
<button type="submit" class="btn btn-success waves-effect waves-light">Submit</button>
....
</form>
当我点击提交按钮时,路线是前往admin/dashboard
路线而不是customer/create
路线
我的路线配置如下
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(true);
$routes->set404Override();
$routes->setAutoRoute(false);
$routes->setPrioritize();