Ok, i use an modified code in the last post, so here is the real code:
action:
public function actionPublicLists()
{
$model=new WordList('search');
$model->unsetAttributes();
if(isset($_GET['WordList']))
$model->attributes=$_GET['WordList'];
$dataProvider = new CActiveDataProvider('Wordlist', array(
'criteria' => array(
'condition' => 'public = :public',
'params' => array(':public'=> 1,),),
'pagination'=> array('pageSize' => 5,),));
$this->render('publiclists',array(
'dataProvider'=>$dataProvider,
'model' => $model
));
}
view:
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $dataProvider,
'filter' => $model,
'template' => "{items}",
'columns' => array(
array(
'name' => 'title',
'header' => 'Title',
),
array(
'name' => 'language1',
'header' => 'Language 1',
),
array(
'name' => 'language2',
'header' => 'Language 2',
),
array(
'name' => 'user',
'header' => 'User',
),
array(
'class' => 'CLinkColumn',
'label' => 'Vocabulary List',
'url' => 'index.php',
),
array(
'class' => 'CLinkColumn',
'label' => 'Subscripe',
'url' => 'index.php',
),
),
)
);
?>
model search:
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,true);
$criteria->compare('title',$this->title,true);
$criteria->compare('language1',$this->language1,true);
$criteria->compare('language2',$this->language2,true);
$criteria->compare('user',$this->user,true);
$criteria->compare('public',$this->public);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
model rules:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
['title, language1, language2, public', 'required'],
['title', 'length', 'max' => 255],
['language1, language2', 'length', 'max' => 128],
//['user', 'length', 'max' => 10],
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, title, language1, language2, user, public', 'safe', 'on'=>'search'),
);
}
Edit: Ok, the problem is that i only want to filter through the rows which are public (public = 1).