Yii Framework Forum: Property is not defined - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Property is not defined Rate Topic: -----

#1 User is offline   Coda 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 20-September 10
  • Location:Kathmandu, Nepal

Posted 11 February 2011 - 06:21 AM

Hello friend
I got an error followed by Property "Messageto.Message" is not defined.

Any idea to solve??

I have two modules: Message and Messageto
In MessageController

public function actionIndex()
{
		/**
	     * acess records of authentic user only
	     */
		$currentUserId = Yii::app()->user->id;	
			
		$criteria =  new CDbCriteria;		
		
		$criteria->with=array('message'=>array('on'=>'message.authorId=t.authorId AND message.messageId=t.messageId AND message.threadOf=0 AND t.memberId='.$currentUserId,'joinType'=>'INNER JOIN'));		
		$criteria->addCondition("t.messageStatusId=1");	
		
		$dataProvider=new CActiveDataProvider('Messageto', array('criteria'=>$criteria));
		
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
		));
}


When I check the query statement, it gives the desired result.

In view :: Index.php


$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'message-grid',
	'dataProvider' => $dataProvider,
	'columns' => array(
			array('name'=>'From',
		      	'type'=>'raw',
		      	'value'=>'Message::thumbImageAndName($data->authorId)',
			),
			array('name'=>'Subject',
		      	'value'=>'$data->Message->messageSubject',				
			),
			array('name'=>'Date',
		      	'value'=>'$data->Message->messageTime',			
			),
			array(
			'class'=>'CButtonColumn',
			),
		),		
	));

0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 11 February 2011 - 08:32 AM

Is the relation message properly set?
-1

#3 User is offline   Coda 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 20-September 10
  • Location:Kathmandu, Nepal

Posted 14 February 2011 - 12:52 AM

View Postzaccaria, on 11 February 2011 - 08:32 AM, said:

Is the relation message properly set?


The relation for model Message is:

return array(
			'messageto' => array(self::HAS_MANY,'Messageto','messageId'),				
		);

And for model Messageto is:


return array(
			'message'=>array(self::BELONGS_TO,'Message','messageId'),			
			);

0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,358
  • Joined: 12-October 09
  • Location:Croatia

Posted 14 February 2011 - 02:22 AM

Could be the first letter case...

note that the error say "Messageto.Message" (Message with first letter upercase)... but the relation in Messageto is "message" (first letter lowercase)

so instead of
'value'=>'$data->Message->messageSubject', 


you would use
'value'=>'$data->message->messageSubject', 

Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   Coda 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 20-September 10
  • Location:Kathmandu, Nepal

Posted 15 February 2011 - 01:55 AM

View Postmdomba, on 14 February 2011 - 02:22 AM, said:

Could be the first letter case...

note that the error say "Messageto.Message" (Message with first letter upercase)... but the relation in Messageto is "message" (first letter lowercase)

so instead of
'value'=>'$data->Message->messageSubject', 


you would use
'value'=>'$data->message->messageSubject', 



Thanks mdombaPosted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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