View Communicates With Model. Wrong?

I just finished reading this book and I saw that in various places, the Model’s methods are being called directly from the View.

For instance in file: trackstar/protected/views/issue/_form.php

there is this code:




<div class="row">

	<?php echo $form->labelEx($model,'type_id'); ?>

	<?php echo $form->dropDownList($model,'type_id', $model->getTypeOptions()); ?>

	<?php echo $form->error($model,'type_id'); ?>

</div>

Wouldn’t that break the MVC practices/rules that the View should not be aware of the Model and instead the controller has to give these values directly to the View?

Or is this totally accepted in Yii?


Model-name::model()->getTypeOptions());

this is the standard use. but if we know that the model itself we can call like that.

My opinion is that you can use the bussiness model’s properties anywhere, as long as its generation and integrity are hidden and guaranteed within the model’s code. In fact, passing (bussiness) model objects to the view layer is the cleanest, simplest, and most direct way of providing information without artificially multiplying ad-hoc data carriers all over the application, or overloading the controllers with too much knowledge of the view’s detailed needs. MVC at its best.