Answer the question
In order to leave comments, you need to log in
How to properly organize search models for CGridView in Yii1?
Good afternoon, I
have a Users model , I want only active users to be displayed in the CGridView , at the same time I want filters by columns to work:
class Users extends ActiveRecord
{
...
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id' ,$this->id);
$criteria->compare('name' ,$this->name,true);
$criteria->compare('role_id' ,$this->role_id);
$criteria->compare('email' ,$this->email,true);
$criteria->compare('password' ,$this->password,true);
$criteria->compare('telephone' ,$this->telephone,true);
$criteria->compare('sys_date' ,$this->sys_date);
$criteria->compare('sys_date_update' ,$this->sys_date_update);
$criteria->compare('sys_user' ,$this->sys_user);
$criteria->compare('exist' ,$this->exist);
$criteria->condition = 'exist != 2';
return new CActiveDataProvider($this,
[
'criteria' => $criteria,
'pagination'=>
[
'pageSize'=>100
],
]);
}
...
}
// $criteria->condition = 'exist != 2';
Answer the question
In order to leave comments, you need to log in
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id' ,$this->id);
$criteria->compare('name' ,$this->name,true);
$criteria->compare('role_id' ,$this->role_id);
$criteria->compare('email' ,$this->email,true);
$criteria->compare('password' ,$this->password,true);
$criteria->compare('telephone' ,$this->telephone,true);
$criteria->compare('sys_date' ,$this->sys_date);
$criteria->compare('sys_date_update' ,$this->sys_date_update);
$criteria->compare('sys_user' ,$this->sys_user);
$criteria->compare('exist', '<>' . 2);
return new CActiveDataProvider($this,
[
'criteria' => $criteria,
'pagination'=>
[
'pageSize'=>100
],
]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question