Yii Framework Forum: Renderpartial Membuat Error: Property Is Not Defined - Yii Framework Forum

Jump to content

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

Renderpartial Membuat Error: Property Is Not Defined Mencoba menggabungkan view dari model lain Rate Topic: -----

#1 User is offline   agus kianto 

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

Posted 05 September 2013 - 02:42 AM

Halo semua,

Saya sedang menggabungkan view photo ke dalam view album dengan cara menambahkan renderPartial ke dal am view.php dari album:

<?php
/* @var $this AlbumController */
/* @var $model Album */

$this->breadcrumbs=array(
'Albums'=>array('index'),
$model->name,
);

$this->menu=array(
array('label'=>'List Album', 'url'=>array('index')),
array('label'=>'Create Album', 'url'=>array('create')),
array('label'=>'Update Album', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Delete Album', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Album', 'url'=>array('admin')),
);
?>

<h1><?php echo CHtml::encode($model->name); ?></h1>
<p class="By">created by: <?php echo CHtml::encode($model->owner->fullName()); ?> on <span class="Date"><?php echo $model->created_dt; ?></span></p>
<p class=""><?php echo CHtml::encode($model->description); ?></p>

<?php
$this->renderPartial('/photo/index',array('dataProvider'=>$photos));
?>

Namun, masalahnya: $this->renderPartial('/photo/index',array('dataProvider'=>$photos)); membuat error:

CException

Property "Photo.name" is not defined.

/Library/WebServer/Documents/yii/db/ar/CActiveRecord.php(143)

131 */
132 public function __get($name)
133 {
134 if(isset($this->_attributes[$name]))
135 return $this->_attributes[$name];
136 elseif(isset($this->getMetaData()->columns[$name]))
137 return null;
138 elseif(isset($this->_related[$name]))
139 return $this->_related[$name];
140 elseif(isset($this->getMetaData()->relations[$name]))
141 return $this->getRelated($name);
142 else
143 return parent::__get($name);
144 }
145
146 /**
147 * PHP setter magic method.
148 * This method is overridden so that AR attributes can be accessed like properties.
149 * @param string $name property name
150 * @param mixed $value property value
151 */
152 public function __set($name,$value)
153 {
154 if($this->setAttribute($name,$value)===false)
155 {
Stack Trace
#0
+ /Library/WebServer/Documents/yii/db/ar/CActiveRecord.php(143): CComponent->__get("name")
#1
– /Library/WebServer/Documents/photogallery/protected/views/album/_view.php(9): CActiveRecord->__get("name")
04 /**CB-3.2**/
05 ?>
06
07 <div class="view">
08
09 <h2><?php echo CHtml::encode($data->name);?></h2>
10 <p><?php /**CB 8.3 if ($data->categories) echo "(".CHtml::encode($data->categories->option_value).")";**/ ?></p>
11 <?php
12 if ($data->photos)
13 echo CHtml::link(
14 CHtml::image($data->photos[0]->getThumb(),CHtml::encode($data->photos[0]->alt_text),array()),
#2
+ /Library/WebServer/Documents/yii/web/CBaseController.php(130): require("/Library/WebServer/Documents/photogallery/protected/views/album/...")
#3
+ /Library/WebServer/Documents/yii/web/CBaseController.php(95): CBaseController->renderInternal("/Library/WebServer/Documents/photogallery/protected/views/album/...", array("index" => 0, "data" => Photo, "widget" => CListView), false)
#4
+ /Library/WebServer/Documents/yii/zii/widgets/CListView.php(281): CBaseController->renderFile("/Library/WebServer/Documents/photogallery/protected/views/album/...", array("index" => 0, "data" => Photo, "widget" => CListView))
#5
+ /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(160): CListView->renderItems()
#6
unknown(0): CBaseListView->renderSection(array("{items}", "items"))
#7
+ /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(143): preg_replace_callback("/{(\w+)}/", array(CListView, "renderSection"), "{summary} {sorter} {items} {pager}")
#8
+ /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(128): CBaseListView->renderContent()
#9
+ /Library/WebServer/Documents/yii/web/CBaseController.php(173): CBaseListView->run()
#10
– /Library/WebServer/Documents/photogallery/protected/views/photo/index.php(24): CBaseController->widget("zii.widgets.CListView", array("dataProvider" => CActiveDataProvider, "itemView" => "_view"))
19 <h1>Photos</h1>
20
21 <?php $this->widget('zii.widgets.CListView', array(
22 'dataProvider'=>$dataProvider,
23 'itemView'=>'_view',
24 )); ?>
25
26 <?php
27 $colorbox->addInstance("a[rel=\'colorBox\']",array('maxHeight'=>'90%', 'maxWidth'=>'90%'));
28 ?>
29
#11
+ /Library/WebServer/Documents/yii/web/CBaseController.php(126): require("/Library/WebServer/Documents/photogallery/protected/views/photo/...")
#12
+ /Library/WebServer/Documents/yii/web/CBaseController.php(95): CBaseController->renderInternal("/Library/WebServer/Documents/photogallery/protected/views/photo/...", array("dataProvider" => CActiveDataProvider), true)
#13
+ /Library/WebServer/Documents/yii/web/CController.php(869): CBaseController->renderFile("/Library/WebServer/Documents/photogallery/protected/views/photo/...", array("dataProvider" => CActiveDataProvider), true)
#14
– /Library/WebServer/Documents/photogallery/protected/views/album/view.php(24): CController->renderPartial("/photo/index", array("dataProvider" => CActiveDataProvider))
19 <h1><?php echo CHtml::encode($model->name); ?></h1>
20 <p class="By">created by: <?php echo CHtml::encode($model->owner->fullName()); ?> on <span class="Date"><?php echo $model->created_dt; ?></span></p>
21 <p class=""><?php echo CHtml::encode($model->description); ?></p>
22
23 <?php
24 $this->renderPartial('/photo/index',array('dataProvider'=>$photos));
25 ?>
#15
+ /Library/WebServer/Documents/yii/web/CBaseController.php(126): require("/Library/WebServer/Documents/photogallery/protected/views/album/...")
#16
+ /Library/WebServer/Documents/yii/web/CBaseController.php(95): CBaseController->renderInternal("/Library/WebServer/Documents/photogallery/protected/views/album/...", array("model" => Album, "photos" => CActiveDataProvider), true)
#17
+ /Library/WebServer/Documents/yii/web/CController.php(869): CBaseController->renderFile("/Library/WebServer/Documents/photogallery/protected/views/album/...", array("model" => Album, "photos" => CActiveDataProvider), true)
#18
+ /Library/WebServer/Documents/yii/web/CController.php(782): CController->renderPartial("view", array("model" => Album, "photos" => CActiveDataProvider), true)
#19
+ /Library/WebServer/Documents/photogallery/protected/controllers/AlbumController.php(64): CController->render("view", array("model" => Album, "photos" => CActiveDataProvider))
#20
unknown(0): AlbumController->actionView("2")
#21
+ /Library/WebServer/Documents/yii/web/actions/CAction.php(108): ReflectionMethod->invokeArgs(AlbumController, array("2"))
#22
+ /Library/WebServer/Documents/yii/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(AlbumController, ReflectionMethod, array("id" => "2"))
#23
+ /Library/WebServer/Documents/yii/web/CController.php(308): CInlineAction->runWithParams(array("id" => "2"))
#24
+ /Library/WebServer/Documents/yii/web/filters/CFilterChain.php(133): CController->runAction(CInlineAction)
#25
+ /Library/WebServer/Documents/yii/web/filters/CFilter.php(40): CFilterChain->run()
#26
+ /Library/WebServer/Documents/yii/web/CController.php(1145): CFilter->filter(CFilterChain)
#27
+ /Library/WebServer/Documents/yii/web/filters/CInlineFilter.php(58): CController->filterAccessControl(CFilterChain)
#28
+ /Library/WebServer/Documents/yii/web/filters/CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#29
+ /Library/WebServer/Documents/yii/web/CController.php(291): CFilterChain->run()
#30
+ /Library/WebServer/Documents/yii/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete"))
#31
+ /Library/WebServer/Documents/yii/web/CWebApplication.php(282): CController->run("view")
#32
+ /Library/WebServer/Documents/yii/web/CWebApplication.php(141): CWebApplication->runController("album/view")
#33
+ /Library/WebServer/Documents/yii/base/CApplication.php(169): CWebApplication->processRequest()
#34
+ /Library/WebServer/Documents/photogallery/www/index.php(18): CApplication->run()
2013-09-05 14:41:30 Apache/2.2.21 (Unix) DAV/2 PHP/5.3.10 with Suhosin-Patch Yii Framework/1.1.13
Application Log
Timestamp Level Category Message
14:41:30.911859 error exception.CException
exception 'CException' with message 'Property "Photo.name" is not defined.'
in /Library/WebServer/Documents/yii/base/CComponent.php:130
Stack trace:
#0 /Library/WebServer/Documents/yii/db/ar/CActiveRecord.php(143):
CComponent->__get('name')
#1
/Library/WebServer/Documents/photogallery/protected/views/album/_view.php(9):
CActiveRecord->__get('name')
#2 /Library/WebServer/Documents/yii/web/CBaseController.php(130):
require('/Library/WebSer...')
#3 /Library/WebServer/Documents/yii/web/CBaseController.php(95):
CBaseController->renderInternal('/Library/WebSer...', Array, false)
#4 /Library/WebServer/Documents/yii/zii/widgets/CListView.php(281):
CBaseController->renderFile('/Library/WebSer...', Array)
#5 /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(160):
CListView->renderItems()
#6 [internal function]: CBaseListView->renderSection(Array)
#7 /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(143):
preg_replace_callback('/{(\w+)}/', Array, '{summary}?{sort...')
#8 /Library/WebServer/Documents/yii/zii/widgets/CBaseListView.php(128):
CBaseListView->renderContent()
#9 /Library/WebServer/Documents/yii/web/CBaseController.php(173):
CBaseListView->run()
#10
/Library/WebServer/Documents/photogallery/protected/views/photo/index.php(24):
CBaseController->widget('zii.widgets.CLi...', Array)
#11 /Library/WebServer/Documents/yii/web/CBaseController.php(126):
require('/Library/WebSer...')
#12 /Library/WebServer/Documents/yii/web/CBaseController.php(95):
CBaseController->renderInternal('/Library/WebSer...', Array, true)
#13 /Library/WebServer/Documents/yii/web/CController.php(869):
CBaseController->renderFile('/Library/WebSer...', Array, true)
#14
/Library/WebServer/Documents/photogallery/protected/views/album/view.php(24):
CController->renderPartial('/photo/index', Array)
#15 /Library/WebServer/Documents/yii/web/CBaseController.php(126):
require('/Library/WebSer...')
#16 /Library/WebServer/Documents/yii/web/CBaseController.php(95):
CBaseController->renderInternal('/Library/WebSer...', Array, true)
#17 /Library/WebServer/Documents/yii/web/CController.php(869):
CBaseController->renderFile('/Library/WebSer...', Array, true)
#18 /Library/WebServer/Documents/yii/web/CController.php(782):
CController->renderPartial('view', Array, true)
#19
/Library/WebServer/Documents/photogallery/protected/controllers/AlbumController.php(64):
CController->render('view', Array)
#20 [internal function]: AlbumController->actionView('2')
#21 /Library/WebServer/Documents/yii/web/actions/CAction.php(108):
ReflectionMethod->invokeArgs(Object(AlbumController), Array)
#22 /Library/WebServer/Documents/yii/web/actions/CInlineAction.php(47):
CAction->runWithParamsInternal(Object(AlbumController),
Object(ReflectionMethod), Array)
#23 /Library/WebServer/Documents/yii/web/CController.php(308):
CInlineAction->runWithParams(Array)
#24 /Library/WebServer/Documents/yii/web/filters/CFilterChain.php(133):
CController->runAction(Object(CInlineAction))
#25 /Library/WebServer/Documents/yii/web/filters/CFilter.php(40):
CFilterChain->run()
#26 /Library/WebServer/Documents/yii/web/CController.php(1145):
CFilter->filter(Object(CFilterChain))
#27 /Library/WebServer/Documents/yii/web/filters/CInlineFilter.php(58):
CController->filterAccessControl(Object(CFilterChain))
#28 /Library/WebServer/Documents/yii/web/filters/CFilterChain.php(130):
CInlineFilter->filter(Object(CFilterChain))
#29 /Library/WebServer/Documents/yii/web/CController.php(291):
CFilterChain->run()
#30 /Library/WebServer/Documents/yii/web/CController.php(265):
CController->runActionWithFilters(Object(CInlineAction), Array)
#31 /Library/WebServer/Documents/yii/web/CWebApplication.php(282):
CController->run('view')
#32 /Library/WebServer/Documents/yii/web/CWebApplication.php(141):
CWebApplication->runController('album/view')
#33 /Library/WebServer/Documents/yii/base/CApplication.php(169):
CWebApplication->processRequest()
#34 /Library/WebServer/Documents/photogallery/www/index.php(18):
CApplication->run()
#35 {main}
REQUEST_URI=/album/2
HTTP_REFERER=http://photogallery.lan/album
---

Apakah ada yang pernah mengalami ini sebelumnya?
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