Yii2 带参数的按钮 [英] Yii2 Button with Parameter

查看:24
本文介绍了Yii2 带参数的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Yii2 项目中有这个按钮:

I have this button in my Yii2 project:

Html::a('label', ['/attributes/index'], ['class'=>'btn btn-primary']) ;

按钮位于页面中:

/site/view

现在我想要做的是当这个按钮从站点/视图页面被点击到属性/索引页面时传递一个参数.

Now what I want to do is pass a parameter when this button gets clicked to the attributes/index page from the site/view page.

更具体地说,它是我想从我正在查看的数据库中传递特定记录的 ID.

To be more specific it is the ID that I want to pass of a particular record from a DB I am viewing.

干杯.

推荐答案

您可以在路由后将参数作为键 => 值对传递:

You can pass parameters as key => value pairs after the route:

Html::a('label', ['/attributes/index', 'id' => $id], ['class'=>'btn btn-primary']) ;

查看 Yii2 文档:http://www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#toRoute()-detail

See the Yii2 docs: http://www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#toRoute()-detail

这篇关于Yii2 带参数的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆