Yii link with [ as a parameter

房东的猫 提交于 2019-12-11 20:34:12

问题


With GII I have created a list of records. I use the admin view so they are in a table view. On top of the table it is the search with a status for the records. When the status dropdown is changed I submit the form and the table gets searched. I want the default view of the admin to show only the active records so I want to create a link in the menu to this: medium/admin/?Medium[status]=active The actual link of course is medium/admin/?Medium%5Bstatus%5D=active

I have tried to do it with:

CHtml::link('Mediums', array("medium/admin", array('Medium[status]' => 'active')))
CHtml::link('Mediums', array("medium/admin", array('Medium%5Bstatus%5D' => 'active'))) 
CHtml::link('Mediums', array("medium/admin", array('Medium' => array('status' => 'active')))) 

But all of the links are incorrect so the default view of the table is with all the records shown.

What is the correct way to create such a link?

Thank you.


回答1:


http://www.yiiframework.com/doc/api/1.1/CHtml#link-detail and http://www.yiiframework.com/wiki/48/ will be usefull for you.

CHtml::link(CHtml::encode('Mediums'),array("medium/admin", "status"=>"active"));

Then ensure that in your controller you have something like this:

public function actionAdmin($status)

Now you ca use 'status' in your action.



来源:https://stackoverflow.com/questions/16131408/yii-link-with-as-a-parameter

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