[英]Yii CGridView search with “&” contains attributes
我正在使用Yii 1.1.15框架。
我无法在查询字符串的属性(例如brand_name)中搜索&作为符号。 如果输入&符号,则URL如下所示:
localhost/doctors/brand/?brand[brand_name]=&&brand[brand_status]=
这里的情况是brand[brand_name]=&
。 它不考虑&
并且作为下一个参数终止,如果我只是对该字符进行编码,它将变为: %26
因此url变为localhost/doctors/brand/?brand[brand_name]=%26&brand[brand_status]=
和它给出正确的结果。
但是如何编码yii CGridView过滤器文本数据呢?
提前致谢。
CGridView
使用GET作为默认的ajax类型,而&
是HTTP请求的GET参数的定界符,因此您不能将此字符用作搜索字符串的一部分。 我认为解决方案是对ajax请求使用POST而不是GET。 要将CGridView ajax参数从GET更改为POST,请将'ajaxType' => "POST"
到您的cgridview选项中:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'...',
'ajaxType' => "POST",
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
...
),
)); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.