Skip to content

Instantly share code, notes, and snippets.

@hscstudio
Created March 10, 2016 14:46
Show Gist options
  • Save hscstudio/43664c92242852547df4 to your computer and use it in GitHub Desktop.
Save hscstudio/43664c92242852547df4 to your computer and use it in GitHub Desktop.
public function actionIndex($year='')
{
if(empty($year)) $year=date('Y');
$searchModel = new TrainingSearch();
$queryParams = Yii::$app->request->getQueryParams();
if($year!='all'){
$queryParams['TrainingSearch']=[
'year' => $year,
];
}
$queryParams=yii\helpers\ArrayHelper::merge(Yii::$app->request->getQueryParams(),$queryParams);
$dataProvider = $searchModel->search($queryParams);
$dataProvider->getSort()->defaultOrder = ['start'=>SORT_ASC,'end'=>SORT_ASC];
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'year' => $year,
]);
}
// combobox
$year = ['all', 2016, 2015, 2014, 2013];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment