Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter for username in assignments. #81

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions controllers/AssignmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ class AssignmentController extends AuthController
*/
public function actionIndex()
{
$dataProvider = new CActiveDataProvider($this->module->userClass);
$model = new $this->module->userClass('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET[$this->module->userClass]))
$model->attributes=$_GET[$this->module->userClass];

$this->render('index', array(
'dataProvider' => $dataProvider
'model' => $model
));
}

Expand Down Expand Up @@ -127,4 +130,4 @@ protected function getAssignmentOptions($userId)

return $options;
}
}
}
7 changes: 4 additions & 3 deletions views/assignment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

<?php $this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'striped hover',
'dataProvider' => $dataProvider,
'emptyText' => Yii::t('AuthModule.main', 'No assignments found.'),
'template'=>"{items}\n{pager}",
'filter' => $model,
'dataProvider' => $model->search(),
'emptyText' => Yii::t('AuthModule.main', 'No assignments found.'),
'template'=>"{items}\n{pager}",
'columns' => array(
array(
'header' => Yii::t('AuthModule.main', 'User'),
Expand Down
8 changes: 8 additions & 0 deletions widgets/AuthAssignmentNameColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ protected function renderDataCellContent($row, $data)
{
echo CHtml::link(CHtml::value($data, $this->nameColumn), array('view', 'id'=>$data->{$this->idColumn}));
}

/**
* Renders the filter cell content.
*/
protected function renderFilterCellContent()
{
echo CHtml::activeTextField($this->grid->filter, $this->getNameColumn(), array('id'=>false));
}
}