I’m working on chapter 5. I just found the following problem. The code on page 110 does not match the code in the code zip file. I follow the book, copy all the code from the book to my own code, and got a problem with the code on page 110 for protected/views/issue/_view.php.
This is the code from the book:
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->name), array('issue/view', 'id'=>$data->id)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('description')); ?>:</b>
<?php echo CHtml::encode($data->description); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('type_id'));?>:</b>
<?php echo CHtml::encode($data->type_id); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('status_id'));?>:</b>
<?php echo CHtml::encode($data->status_id); ?>
</div>
When using this code, you get errors because of type_id and status_id. The error you get is:
CException Property "Project.type_id" is not defined.
This is the code from the zip:
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
<br />
<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 />
<b><?php echo CHtml::encode($data->getAttributeLabel('create_time')); ?>:</b>
<?php echo CHtml::encode($data->create_time); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('create_user_id')); ?>:</b>
<?php echo CHtml::encode($data->create_user_id); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('update_time')); ?>:</b>
<?php echo CHtml::encode($data->update_time); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('update_user_id')); ?>:</b>
<?php echo CHtml::encode($data->update_user_id); ?>
<br />
</div>
So the status_id and type_id are gone here, and replaced by the create and update user and time.