Reputation: 780
I have the following DropDownList
where I select the category to update the graph. Everything was working fine until I enable "enablePrettyUrl
".
Now when I select any value in the DropDownList appears the error
"Not Found (# 404)".
What could be wrong?
VIEW:
<?php
$this->registerJs('var submit = function (val){if (val > 0) {
window.location.href = "' . Url::to(['/dashboard/accomplishment']) . '&category_id=" + val;
}
}', View::POS_HEAD);
echo Html::activeDropDownList($model, 'category_id', 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'=>Yii::t('app','Select'),'class'=>'form-control']);
?>
CONTROLLER:
public function actionAccomplishment()
{
$model = new Dashboard();
$url = Yii::$app->getRequest()->getQueryParam('category_id');
$category_id = isset($url) ? $url : 0;
$thisyear = date('Y');
$thismonth = date('m');
$user = Yii::$app->user->identity->id;
My urlManager:
'urlManager' => [
'class' => 'yii\web\UrlManager',
'showScriptName' => false,
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
Upvotes: 0
Views: 65
Reputation: 780
This way work:
window.location.href = "' . Url::to(['/dashboard/accomplishment']) . '?category_id=" + val;
Upvotes: 1
Reputation: 133400
try adding /
and removing & this way
window.location.href = "' . Url::to(['/dashboard/accomplishment/']) . 'category_id=" + val;
Upvotes: 1