Answer the question
In order to leave comments, you need to log in
Why isn't a parameter passed to the controller action?
Why is the "id" parameter not being passed to the controller action? urlManager uncommented
Address bar looks like this: http://parms/blog/site/index/id/6
Controller action code:
public function actionIndex($id)
{
$this->render('index', array('id'=>$id));
}
<?php
/* @var $this SiteController */
/* @var $id int */
$this->pageTitle=Yii::app()->name;
echo $id;
CVarDumper::dump($id);
echo $id;
?>
Answer the question
In order to leave comments, you need to log in
The problem is obviously not in rendering and routes, but in passing the parameter itself. You have not shown the link anywhere and what parameter is passed there. Perhaps you are $id
passing in a parameter null
. Look carefully. You can check this very simply by executing a simple command not in the template, but in the controller:
public function actionIndex($id)
{
var_dump($id); die();
}
return
:public function actionIndex($id)
{
return $this->render('index', array('id'=>$id));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question