Yii Framework Forum: Agile Web Application Development With Yii1.1 And Php5 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Agile Web Application Development With Yii1.1 And Php5 Agile Web Application Development with Yii1.1 and PHP5

#1 User is offline   agus kianto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-January 13

Posted 15 January 2013 - 12:28 PM

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.yiiframew...k-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.

Attached File(s)


0

#2 User is offline   agus kianto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-January 13

Posted 15 January 2013 - 12:34 PM

I am trying too add issues below each project view.
0

#3 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 477
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 15 January 2013 - 03:20 PM

The Stacktrace would have been helpfull in your image ;-)
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.
0

#4 User is offline   agus kianto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-January 13

Posted 15 January 2013 - 05:05 PM

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

#5 User is offline   agus kianto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 07-January 13

Posted 15 January 2013 - 05:12 PM

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'=>$issueDataProvider,
'itemView'=>'/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?
0

#6 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 477
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 15 January 2013 - 05:49 PM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users