Hi My Model Name is AuditTest:
I have problem with my widget
The Audit trail function does not work… i mean when ever i make any update there is not activity in the audit table
Here is my error
CException
Property "Audittest.id" is not defined.
C:\wamp\www\yii-install\framework\db\ar\CActiveRecord.php(110)
098 */
099 public function __get($name)
100 {
101 if(isset($this->_attributes[$name]))
102 return $this->_attributes[$name];
103 else if(isset($this->getMetaData()->columns[$name]))
104 return null;
105 else if(isset($this->_related[$name]))
106 return $this->_related[$name];
107 else if(isset($this->getMetaData()->relations[$name]))
108 return $this->getRelated($name);
109 else
110 return parent::__get($name);
111 }
112
113 /**
114 * PHP setter magic method.
115 * This method is overridden so that AR attributes can be accessed like properties.
116 * @param string $name property name
117 * @param mixed $value property value
118 */
119 public function __set($name,$value)
120 {
121 if($this->setAttribute($name,$value)===false)
122 {
Stack Trace
#0
+ C:\wamp\www\yii-install\framework\db\ar\CActiveRecord.php(110): CComponent->__get("id")
#1
– C:\wamp\www\audittest\protected\modules\auditTrail\widgets\portlets\ShowAuditTrail.php(30): CActiveRecord->__get("id")
25
26 /**
27 * Sets the title of the portlet
28 */
29 public function init() {
30 $this->title = "Audit Trail For " . get_class($this->model) . " " . $this->model->id;
31 parent::init();
32 }
33
34 /**
35 * generates content of widget the widget.
#2
+ C:\wamp\www\yii-install\framework\web\CBaseController.php(140): ShowAuditTrail->init()
#3
+ C:\wamp\www\yii-install\framework\web\CBaseController.php(165): CBaseController->createWidget("application.modules.auditTrail.widgets.portlets.ShowAuditTrail", array(Audittest))
#4
– C:\wamp\www\audittest\protected\views\audittest\admin.php(45): CBaseController->widget("application.modules.auditTrail.widgets.portlets.ShowAuditTrail", array(Audittest))
40 <?php $this->widget(
41 'application.modules.auditTrail.widgets.portlets.ShowAuditTrail',
42 array(
43 'model' => $model,
44 )
45 );?>
46
47 <?php $this->widget('zii.widgets.grid.CGridView', array(
48 'id'=>'audittest-grid',
49 'dataProvider'=>$model->search(),
50 'filter'=>$model,
#5
+ C:\wamp\www\yii-install\framework\web\CBaseController.php(119): require("C:\wamp\www\audittest\protected\views\audittest\admin.php")
#6
+ C:\wamp\www\yii-install\framework\web\CBaseController.php(88): CBaseController->renderInternal("C:\wamp\www\audittest\protected\views/audittest\admin.php", array(Audittest), true)
#7
+ C:\wamp\www\yii-install\framework\web\CController.php(833): CBaseController->renderFile("C:\wamp\www\audittest\protected\views/audittest\admin.php", array(Audittest), true)
#8
+ C:\wamp\www\yii-install\framework\web\CController.php(746): CController->renderPartial("admin", array(Audittest), true)
#9
– C:\wamp\www\audittest\protected\controllers\AudittestController.php(148): CController->render("admin", array(Audittest))
143 if(isset($_GET['Audittest']))
144 $model->attributes=$_GET['Audittest'];
145
146 $this->render('admin',array(
147 'model'=>$model,
148 ));
149 }
150
151 /**
152 * Returns the data model based on the primary key given in the GET variable.
153 * If the data model is not found, an HTTP exception will be raised.
#10
+ C:\wamp\www\yii-install\framework\web\actions\CInlineAction.php(57): AudittestController->actionAdmin()
#11
+ C:\wamp\www\yii-install\framework\web\CController.php(300): CInlineAction->run()
#12
+ C:\wamp\www\yii-install\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction)
#13
+ C:\wamp\www\yii-install\framework\web\filters\CFilter.php(41): CFilterChain->run()
#14
+ C:\wamp\www\yii-install\framework\web\CController.php(1088): CFilter->filter(CFilterChain)
#15
+ C:\wamp\www\yii-install\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)
#16
+ C:\wamp\www\yii-install\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#17
+ C:\wamp\www\yii-install\framework\web\CController.php(283): CFilterChain->run()
#18
+ C:\wamp\www\yii-install\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array("accessControl"))
#19
+ C:\wamp\www\yii-install\framework\web\CWebApplication.php(328): CController->run("admin")
#20
+ C:\wamp\www\yii-install\framework\web\CWebApplication.php(121): CWebApplication->runController("audittest/admin")
#21
+ C:\wamp\www\yii-install\framework\base\CApplication.php(155): CWebApplication->processRequest()
#22
+ C:\wamp\www\audittest\index.php(13): CApplication->run()
2011-02-10 03:32:14 Apache/2.2.17 (Win32) PHP/5.3.5 Yii Framework/1.1.6
My Main.php
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.modules.auditTrail.models.AuditTrail',
'application.modules.auditTrail.AuditTrailModule',
'application.models.*',
'application.components.*',
),
'modules'=>array(
'auditTrail'=>array(),
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'roopesh',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),
*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=edusoft',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);
My Model file
<?php
/**
* This is the model class for table "audittest".
*
* The followings are the available columns in table 'audittest':
* @property string $First_Name
* @property string $Last_Name
* @property string $Gender
*/
class Audittest extends CActiveRecord
{
public function behaviors()
{
return array(
'LoggableBehavior'=>
'application.modules.auditTrail.behaviors.LoggableBehavior',
);
}
/**
* Returns the static model of the specified AR class.
* @return Audittest the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'audittest';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('First_Name, Last_Name, Gender', 'required'),
array('First_Name, Last_Name', 'length', 'max'=>10),
array('Gender', 'length', 'max'=>5),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('First_Name, Last_Name, Gender', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'First_Name' => 'First Name',
'Last_Name' => 'Last Name',
'Gender' => 'Gender',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('First_Name',$this->First_Name,true);
$criteria->compare('Last_Name',$this->Last_Name,true);
$criteria->compare('Gender',$this->Gender,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
}
please let me know if i am missing any thing