关于URL中参数的疑问

Doubts about parameter in the URL

我有以下表格到以下地址:

http://localhost/myapp/web/index.php?r=cashbook%2Faccomplishment

$form = ActiveForm::begin([
        'id' => 'accomplishment-form',
        'options' => ['class' => 'form-horizontal'],
        'action' => Url::to(['/cashbook/accomplishment']),
                'method' => 'get',
]);
$form->field($model, 'category_id')->dropDownList(ArrayHelper::map(
                Category::find()->where(['user_id' => Yii::$app->user->identity->id])
                                ->orderBy("desc_category ASC")
                                ->all(), 'id_category', 'desc_category'),
                ['onchange'=>'this.form.submit()','prompt'=>'-- Select --']); 

ActiveForm::end();

谁处理并生成以下内容URL:

http://localhost/myapp/web/index.php?r=cashbook%2Faccomplishment&Cashbook%5Bcategory_id%5D=18

但我只需要 category_id 值(在 dropDownList 中选择)。也就是说,URL 应该是:

http://localhost/myapp/web/index.php?r=cashbook%2Faccomplishment&category_id=19

如何保持这种状态或只获得 category_id

在视图中添加 registerJs:

$this->registerJs('var submit = function (val){
if (val > 0) {
    window.location.href = "' . Url::to(['/cashbook/accomplishment']) . '/?category_id=" + val;
}
}', View::POS_HEAD);

并且不使用 ActiveForm::begin... 和您的所有代码。而不是使用这个:

echo Html::activeDropDownList($model, 'id_category', ArrayHelper::map(
            Category::find()->where(['user_id' => Yii::$app->user->identity->id])
                            ->orderBy("desc_category ASC")
                            ->all(), 'id_category', 'desc_category'), ['onchange'=>'submit(this.value);','prompt'=>'-- Select --']);