Hi all,
I’m declaring my CActiveRecord in my controller method.
$criteria = new CDbCriteria;
$criteria->with = array('company', 'venue');
if(!$this->checkAccess('Admin')){
$criteria->condition = 'manager_id = :uid AND status > -2';
$criteria->params = array(':uid'=>Yii::app()->user->id);
} else {
$criteria->condition = 'status > -2';
}
$model = new CActiveDataProvider('Events',
array(
'criteria' => $criteria,
'sort' => array(
'defaultOrder'=>'t.added DESC',
'attributes'=>array(
'venue_country_code'=>array(
'asc'=>'venue.country_code ASC',
'desc'=>'venue.country_code DESC',
),
'*',
),
),
)
);
$this->render('management', array(
'model' => $model,
));
I my model I declared venue_company_code, and sorting already works. Also works filter on all relative attributes of my model. My view:
<?php $this->widget('bootstrap.widgets.TbGridView', array(
'id'=>'events-grid',
'dataProvider'=>$model,
'enableSorting'=>true,
'filter'=>new Events,
'columns'=>array(
'added',
...
array(
'name'=>'venue_country_code',
'value'=>'!empty($data->venue->country_code)?$data->venue->country_code:""',
'visible'=>$this->checkAccess('Admin'),
),
),
'itemsCssClass'=>'table table-striped table-hover table-bordered dataTable',
'summaryText' => '',
'htmlOptions'=>array('class'=>''),
)); ?>
Now my venue_company_code filter not works. How can I let it work?
P.S. In CRUD-generated files for sorting and filtering model->search() is using. Can anybody explain me what is the reason of this way?