yii 搜索框无法搜索内容 [ 1.1 版本 ]
前台:
array(
'name'=>'username',
'header'=>Yii::t('user','Username'),
'type'=>'raw',
'htmlOptions'=>array('class'=>'center'),
'value'=>'$data->user->username',
),
模型:
public $username;
public function rules()
{
return array(
array('realName, address, email, mobile, telephone, rebateCardNumber', 'required'),
array('rebateCardNumber', 'numerical', 'integerOnly'=>true),
array('rebateCardNumber,username, balance', 'safe', 'on'=>'search'),
);
}
public function relations()
{
return array(
'user'=>array(self::BELONGS_TO, 'User', array('userid'=>'id')),
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->with = array('user');
if(Rights::getAssignedRole(Yii::app()->user->id, 'Agents')) {
$criteria->addCondition('userid !='.Yii::app()->user->id);
}
$criteria->addCondition('user.type=2');
$criteria->compare('user.username',$this->username,true);
$criteria->compare('realName',$this->realName,true);
$criteria->compare('address',$this->address,true);
$criteria->compare('email',$this->email,true);
$criteria->compare('mobile',$this->mobile,true);
$criteria->compare('telephone',$this->telephone,true);
$criteria->compare('rebateCardNumber',$this->rebateCardNumber);
$criteria->compare('balance',$this->balance);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
搜索框已存在,但输入值无效,提交还是原来样子。原因是为什么?怎么解决?
一叶知秋
注册时间:2015-06-03
最后登录:2015-07-07
在线时长:0小时54分
最后登录:2015-07-07
在线时长:0小时54分
- 粉丝1
- 金钱50
- 威望0
- 积分50