Answer the question
In order to leave comments, you need to log in
CRUD YII2 problem when deleting a record from a table?
Hello! I create an admin panel, generated CRUD via gii for the users table, registered routes in the web.php file. When an entry is deleted from the users table, it redirects to a non-existent page. Interestingly, for the pages for adding and updating a record, I did not prescribe routes, and they work. Help solve the problem.
Answer the question
In order to leave comments, you need to log in
You make return $this->redirect(['index']);
url manager rules
'/' => 'site/index',
'article/short/<id:\d+>' => 'site/article/',
'article/full/<id:\d+>' => 'site/fullarticle/',
'addClick/<idClickBlock:\d+>' => 'site/addclick',
'admin' => 'admin/default/',
'admin/news' => 'admin/news/',
'admin/tizers' => 'admin/tizer/',
'admin/sections' => 'admin/section/',
'admin/users' => 'admin/user/',
['index']
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['admin/news/]);
}
'enableStrictParsing' => true, // чтобы "я не прописывал маршруты,и они работают."
// Base
'<action>' => 'site/<action>',
'<controller>/<action>' => '<controller>/<action>',
'<module>/<controller>/<action>/<id:\w+>' => '<module>/<controller>/<action>',
'<module>/<controller>' => '<module>/<controller>/index',
'<module>/<controller>/<action>' => '<module>/<controller>/<action>',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question