Agile Web Application Development With Yii1.1 And Php5

Hi all,

I’m trying the code of chapter 6 of Agile Web Application Development with Yii1.1 and PHP5 and I got this error:

The "dataProvider" property cannot be empty.

(See attachment to see error)

I have follow the book accordingly and I try to follow along with this link: http://www.yiiframework.com/forum/index.php?/topic/12990-got-stuck-at-chapter-6/

but I still get the same error.

Is there some configuration that I should do with ZII? FYI, I am using mac os x lion.

I am trying too add issues below each project view.

The Stacktrace would have been helpfull in your image :wink:

You are somewhere creating a CGridView or CListView and did not add a dataprovider to it, so it has no data source where it can display data from.

So what should I do? Where can I add a data source?

This is in project controller:

public function actionView($id)

{


	$this->render('view',array('model'=>$this->loadModel($id),));


	


	$issueDataProvider=new CActiveDataProvider('Issue', array(


	         'criteria'=>array(


	           'condition'=>'project_id=:projectId',


	           'params'=>array(':projectId'=>$this->loadModel($id)->id),


	         ),


	         'pagination'=>array(


	           'pageSize'=>1,


	), ));


	       $this->render('view',array(


	         'model'=>$this->loadModel($id),


	         'issueDataProvider'=>$issueDataProvider,


	));


}

This is in /protected/views/project/view.php:

<br>

<h1>Project Issues</h1>

<?php $this->widget(‘zii.widgets.CListView’, array(

 'dataProvider'=&gt;&#036;issueDataProvider,


 'itemView'=&gt;'/issue/_view',

)); ?>

And this is in /protected/views/issue/_view. php

<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(‘descripti on’)); ?>:</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>

What am I missing?

actionView in the first line you call render(). This has to be removed, you have already a render call on the end of that action, where the dataProvider is set.