简体   繁体   中英

yii2 framework: Controller/Action url & without parameters

In my application , I have AdminController with actionupdate, So in YII the path becomes admin/update . Now in order to get certain users info , I use the following path admin/update?id=10 where 10 is the 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? instead of ( admin/update?id=10 ). i don't need the user want to see the id values.

Thank you!

You can send data using POST method instead of GET

With the help of javascript Use an hidden form with post method and a input field. onclick of update button set id to input field and submit form. you will get id in controller's action without showing it in url

use in actionUpdata Yii::$app->user->id;

public function actionUpdate() {
  $empID = Yii::$app->user->id;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM