Answer the question
In order to leave comments, you need to log in
How to get data through a garter?
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'ref-mahala-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'district_id',
'name_ru',
'name_uz',
'name_en',
'address_ru',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('district_id',$this->region['name_ru']);
$criteria->compare('name_ru',$this->name_ru,true);
$criteria->compare('name_en',$this->name_en,true);
$criteria->compare('address_ru',$this->address_ru,true);
$criteria->compare('address_en',$this->address_en,true);
$criteria->compare('sort',$this->sort);
$criteria->compare('active',$this->active);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
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(
'region' => array(self::BELONGS_TO, 'RefRegion', 'district_id'),
);
}
Answer the question
In order to leave comments, you need to log in
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'ref-mahala-grid',
'dataProvider'=>$model->with('region')->search(),
'filter'=>$model,
'columns'=>array(
'id',
// 'district_id',
'region.нужное поле из класса RefRegion'
'name_ru',
'name_uz',
'name_en',
'address_ru',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question