Expose variables to view from controller

I am new to yii. I have used cake and CI before. I used gii to create my models, views, and controllers. One of my models is named Hero. I don’t understand the generated code for HeroController.actionView() and views/hero/_view.php.

The code for HeroController.actionView() loads the model into a variable named $model.



* Displays a particular model.


public function actionView()






However on _view.php the $model fields are referenced like so: $data->name. Why is that? Where did $model go?

<div class="view">

	<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>

	<?php echo CHtml::encode($data->name); ?>

	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('description')); ?>:</b>

	<?php echo CHtml::encode($data->description); ?>

	<br />


According to the docs for the render method there should be a variable named $model in the view.



* @param array data to be extracted into PHP variables and made available to the view script



public function render($view,$data=null,$return=false)

Wow. I feel dumb. I was looking at the wrong view file.

I found $model as expected in views/hero/view.php







	array('label'=>'List Hero', 'url'=>array('index')),

	array('label'=>'Create Hero', 'url'=>array('create')),

	array('label'=>'Update Hero', 'url'=>array('update', 'id'=>$model->id)),

	array('label'=>'Delete Hero', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),

	array('label'=>'Manage Hero', 'url'=>array('admin')),