I am new developer for symfony. How to pass dynamic userId form list page to edit page?. Any one explain to me.
1条回答 默认 最新
- donglu8549 2018-03-25 17:43关注
You can pass it as a parameter like this:
In the twig template, use
<a href="{{ path('name_of_edit_action', {'id' : user.id}) }}">edit user</a>
This is the link that leads to the edit page. Assuming you user object has been passed to the template as 'user'. Ofcourse 'name_of_edit_action' can be anything, as long as it matches the name of the action in the edit controller.
Then in the edit controller, you can catch the user id like this: (hypothetical route, doesn't matter, the point is the {id} part.)
/** * @Route("user/edit/{id}", name="name_of_edit_action") */ public function edit(User $user) { //at this point you have the user object at your disposal and you can pass it to the template as usual }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 eda:门禁系统设计
- ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
- ¥15 376.1电表主站通信协议下发指令全被否认问题
- ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
- ¥15 复杂网络,变滞后传递熵,FDA
- ¥20 csv格式数据集预处理及模型选择
- ¥15 部分网页页面无法显示!
- ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
- ¥15 QTOF MSE数据分析
- ¥15 平板录音机录音问题解决