Hello Friends,
My model name announcement.php
<?php
/**
* This is the model class for table "announcement".
*
* The followings are the available columns in table 'announcement':
* @property integer $id
* @property string $title
* @property string $description
* @property string $status
* @property string $ipaddress
* @property integer $created_by
* @property integer $updated_by
* @property string $created_dt
* @property string $updated_dt
*/
class Announcement extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return Announcement 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 'announcement';
}
/**
* @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('title, ipaddress, created_dt, updated_dt', 'required'),
array('title,description ipaddress', 'required','on'=>'add,update'),
array('created_by, updated_by', 'numerical', 'integerOnly'=>true),
array('title, ipaddress', 'length', 'max'=>255),
array('status', 'length', 'max'=><img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />,
array('description', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, title, description, status, ipaddress, created_by, updated_by, created_dt, updated_dt', '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(
'id' => 'ID',
'title' => 'Title',
'description' => 'Description',
'status' => 'Status',
'ipaddress' => 'Ipaddress',
'created_by' => 'Created By',
'updated_by' => 'Updated By',
'created_dt' => 'Created Dt',
'updated_dt' => 'Updated Dt',
);
}
/**
* 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('id',$this->id);
$criteria->compare('title',$this->title,true);
$criteria->compare('description',$this->description,true);
$criteria->compare('status',$this->status,true);
$criteria->compare('ipaddress',$this->ipaddress,true);
$criteria->compare('created_by',$this->created_by);
$criteria->compare('updated_by',$this->updated_by);
$criteria->compare('created_dt',$this->created_dt,true);
$criteria->compare('updated_dt',$this->updated_dt,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>array(
'attributes'=>array(
'id',
'title',
array(
'name' =>'description',
'type' =>'raw',
'htmlOptions'=>array('style'=>'width:50%'),
),
'ipaddress',
),
),
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
),
));
}
}
my view file (list.php)
<?php
/**
* Action : Listing of the Announcement
* @param :
* @return :
* @author :
*/
$this->breadcrumbs=array(
'Announcement'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Announcement', 'url'=>array('index')),
array('label'=>'Create Announcement', 'url'=>array('create')),
);
?>
<h1>Manage Announcement</h1>
<?php
/** Add, Edit, Delete message display here */
$this->renderPartial('//layouts/_message');
echo CHtml::link("Add Announcement<br>",array('announcement/add'),array('id'=>'manage-inline'));
$this->widget('application.extensions.fancybox.EFancyBox', array(
'target'=>'a#manage-inline',
'config'=>array(
'scrolling' => 'no',
'titleShow' => false,
'width' => '400px',
),
)
);
?>
<?php
$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
$this->widget('zii.widgets.grid.CGridView',
array(
'id'=>'yii-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'ajaxUpdate'=>true,
'afterAjaxUpdate'=>"function(id,data){ $('a#manage-inline').fancybox({'width':'400px','scrolling':'no','titleShow':false}); }",
'columns'=>array(
'id',
'title',
'description',
'ipaddress',
array(
'class'=>'CButtonColumn',
'viewButtonUrl'=>'Yii::app()->createUrl("announcement/view", array("id" => $data["id"]))','viewButtonOptions'=>array('id'=>'manage-inline'),
'updateButtonUrl'=>'Yii::app()->createUrl("announcement/update", array("id" => $data["id"]))','updateButtonOptions'=>array('id'=>'manage-inline'),
'deleteButtonUrl' => 'Yii::app()->createUrl("announcement/delete" , array("id" => $data["id"]))',
'header'=>CHtml::dropDownList('pageSize',$pageSize,
array(10=>10,20=>20,50=>50,100=>100),
array('onchange'=>"$.fn.yiiGridView.update('yii-grid',{ data:{pageSize: $(this).val() }})",)),),
),
));
?>
<
Here I got the error like
plz help me soon.
thanks in advance