[英]yii2 framework: Controller/Action url & without parameters
In my application , I have AdminController with actionupdate, So in YII
the path becomes admin/update
. 在我的应用程序中,我具有带有actionupdate的AdminController,因此在
YII
,路径变为admin/update
。 Now in order to get certain users info , I use the following path admin/update?id=10 where 10
is the empID
. 现在,为了获取某些用户信息,我使用以下路径
admin/update?id=10 where 10
是empID
。
Is there any way to do the same thing without id part of the path, ie I want my path to look like admin/update? 有没有办法在路径的id部分不做同样的事情,即我希望我的路径看起来像admin / update? instead of (
admin/update?id=10
). 而不是(
admin/update?id=10
)。 i don't need the user want to see the id values. 我不需要用户想要查看id值。
Thank you! 谢谢!
You can send data using POST method instead of GET 您可以使用POST方法而不是GET发送数据
With the help of javascript Use an hidden form with post method and a input field. 在javascript的帮助下,使用带有post方法和输入字段的隐藏表单。 onclick of update button set id to input field and submit form.
更新按钮的onclick将ID设置为输入字段并提交表单。 you will get id in controller's action without showing it in url
您将在控制器的操作中获得id而不在url中显示它
use in actionUpdata Yii::$app->user->id;
在actionUpdata
Yii::$app->user->id;
public function actionUpdate() {
$empID = Yii::$app->user->id;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.