誰かが助けてくれるのだろうかと疑問に思います。Yiiフィルターが機能しない
私は同じコントローラー/モデルを使用していますが、異なるモデル機能を使用する私のYiiアプリケーションで2ページあります。私の最初のページは、デフォルトのsearch()をモデルとして使用するかなり標準的な 'admin'ページです(これはうまく機能します)。それにIDが渡されます(URLパラメータから取得されます)。これはうまく動作しますが、ページのフィルタはうまくいかない。
コントローラでは、ID変数を正しく渡さないためだと思います???
ここにいくつかのコードがあります。
モデル:
public function searchByEvent($event_id) {
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id, true);
$criteria->compare('event_id', $this->event_id, true);
$criteria->compare('status_id', $this->status_id, true);
$criteria->compare('checkin_status_id', $this->checkin_status_id, true);
$criteria->compare('guest_of_user_id', $this->guest_of_user_id, true);
$criteria->compare('user_id', $this->user_id, true);
$criteria->compare('assign_group', $this->assign_group, true);
$criteria->with = 'user';
$criteria->compare('user.forename', $this->user_forename, true);
$criteria->compare('user.surname', $this->user_surname, true);
$criteria->compare('user.company', $this->user_company, true);
$criteria->order = 'user.surname ASC';
$criteria->condition = "event_id = :event_id";
$criteria->params=(array(':event_id'=>$event_id));
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination'=>array('pageSize'=>50),
));
}
コントローラー:
public function actionAdminByEvent() {
$model = new EventAttendees('searchByEvent');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['EventAttendees']))
$model->attributes = $_GET['EventAttendees'];
$this->render('webroot.themes.'.Yii::app()->name.'.views.adminEventAttend.adminByEvent', array(
'model' => $model,
));
}
見ます。
$event_id = Yii::app()->getRequest()->getParam('event_id');
this->widget('booster.widgets.TbGridView', array(
'id' => 'event-attendees-grid',
'dataProvider' => $model->searchByEvent($event_id),
'pager' => array(
'class' => 'booster.widgets.TbPager',
'displayFirstAndLast' => true,
),
'filter' => $model,
'template'=>'{summary}{pager}{items}{pager}',
'selectableRows' => 0,
'selectionChanged' => 'function(id){ location.href = "' . $this->createUrl('view') . '/id/"+$.fn.yiiGridView.getSelection(id);}',
'columns' => array(...
誰でもフィルタが間違っているのを見たり、検索の手順が見つからないことがありますか?
あなたのモデルをどうやってルールメソッドを表示するかを教えてください – georaldc