Hi All,
Very new to Yii but tried looking at other similar topics with no success.
I have 2 table c_task, and tay_task_priority. Table c_task includes an id from the other table.
In the view I want to display the name in the table tay_task_priority according to the relevant id.
I get the CGridView with the information from the c_task table while the tay_task_priority column is empty.
My View is:
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'ctask-grid',
'dataProvider'=>$model->tay_search(),
// ‘filter’=>$model,
'columns'=>array(
'description',
'priority',
'tay_task_priority.priority_name',
array( 'class'=>'CButtonColumn', ),
),
));
?>
Main model includes my search function as follows:
public function tay_search()
{
$criteria=new CDbCriteria;
$criteria->alias = 'ctask';
$criteria->join = 'JOIN tay_task_priority ON tay_task_priority.priority_id=ctask.priority';
$criteria->compare('user_id',Yii::app()->user->getState('appuserid'));
return new CActiveDataProvider( $this , array('criteria'=>$criteria, ));
}
The Controller piece is:
public function actionTayAdmin()
{
$model=new CTask('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['CTask']))
$model->attributes=$_GET['CTask'];
$this->render('tayadmin',array('model'=>$model,
));
}
Can someone tell me how to do it?
Thanks,
Yoavre