$this->getProject()->id vs $model->project_id

When I look at /views/issue/create.php I see this code:


$this->menu=array(

	array('label'=>'List Issue', 'url'=>array('index', 'pid'=>$model->project_id)),

	array('label'=>'Manage Issue', 'url'=>array('admin', 'pid'=>$model->project_id)),

);

Which uses: ‘pid’=>$model->project_id

When I look at /views/issue/index.php I see this code:


$this->menu=array(

	array('label'=>'Create Issue', 'url'=>array('create', 'pid'=>$this->getProject()->id)),

	array('label'=>'Manage Issue', 'url'=>array('admin', 'pid'=>$this->getProject()->id)),

);

Which uses: ‘pid’=>$this->getProject()->id

Why this difference? And why can’t I use ‘pid’=>$model->project_id in /views/issue/index.php?

Somehow it doesn’t look very consistent to me.

Hi Enrico

It depends

If you mentioned in controller action in the first case the

$model->project_id = $this->_project->id;

set the project_id and pass $mode in the view, so $model->project_id is available in view file

In the second case the view access this id directly from controller ($this->getProject()->id)

So there is no difference between these approaches! The author reveal to you a few ways to do that :)