hide a id in url yii2 using urlManager

血红的双手。 提交于 2019-12-20 06:47:03

问题


'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>'

I have written this rule in url manager so that it hide id during update action i want the url should be / the id should be hidden. But no luck. eg: I have this url mysite.com/controller/update/1 i want the url to be mysite.com/controller/update


回答1:


What you are trying to achieve is impossible and useless.

Think about it logically. Action in this case simply won't know exactly what model should be loaded and updated.

I see only one possible use case of that.

When you load page post/update, then select post from list to update and load it with AJAX.

In this case just remove id from action parameters, you don't need to write additional url rules for that.



来源:https://stackoverflow.com/questions/29025994/hide-a-id-in-url-yii2-using-urlmanager

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!