Yii2 Pretty URL params

时间:2018-05-22 06:30:29

标签: yii2

我为yii2高级设置了漂亮的网址 在config / main.php

'urlManager' => [
            'class'=>'yii\web\UrlManager', 
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '/' => 'site/index',
            ],
        ],

的.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

某个控制器

$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);

但是来自gridView $ searchModel的查询过滤器仍然很脏,我可以像一些/ action一样漂亮吗?name = jack& shift_id = 1没有UserSearch [name] = jack?

some/action?UserSearch%5Bname%5D=jack&UserSearch%5Bshift_id%5D=1&UserSearch%5Bmanager_id%5D=176

1 个答案:

答案 0 :(得分:2)

您应该在搜索模型中覆盖angular-d3-charts,以返回空字符串:

public function formName() {
    return '';
}