Doubts about parameter in the URL


I have the following form to the address below:


<?php $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 --'])  ?>

<?php ActiveForm::end(); ?>

Who processes and generates the following URL:


But I need only the category_id value (selected in dropDownList). That is, the URL should be:


How to stay that way or get just the category_id

For those who have the same problem tracking solution:

In view add registerJs:

$this->registerJs('var submit = function (val){

if (val > 0) {

	window.location.href = "' . Url::to(['/cashbook/accomplishment']) . '/?category_id=" + val;


}', View::POS_HEAD);

And not use ActiveForm::begin… and all your code. Instead of use this:

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 --']);

thanks to vitalik_74