<?php
namespace app\widgets;
use Yii;
use Yii\helpers\Html;
use Yii\widgets\LinkPager;
class ILinkPager extends yii\widgets\LinkPager
{
public function __construct() {
$this->firstPageLabel = Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-fast-backward', 'title' => Yii::t('app', 'First page'), ]);
$this->prevPageLabel = Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-backward', 'title' => Yii::t('app', 'Previous page'), ]);
$this->nextPageLabel = Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-forward', 'title' => Yii::t('app', 'Next page'), ]);
$this->lastPageLabel = Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-fast-forward', 'title' => Yii::t('app', 'Last page'), ]);
}
}
$config = [
...
'container' => [
'definitions' => [
'yii\grid\GridView' => [
'pager' => [
'class' => 'app\widgets\ILinkPager',
],
],
],
],
...
];
$count = count(Types::find()->where([ 'name' => $validName ])->all());
$this->assertGreaterThan(0, $count);
$this->assertEquals(1, $count);
$this->tester->seeInDatabase('types', [ 'name' => $validName ]);
$this->tester->haveInDatabase('types', [ 'name' => $validName ]);
public function actionIndex()
{
$searchModel = new ItemsSearch();
if (isset(Yii::$app->request->queryParams['id'])) {
$id = Yii::$app->request->queryParams['id'];
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->select(Items::tableName() . '.id');
$pageSize = $dataProvider->pagination->pageSize;
$dataProvider->pagination = FALSE;
$rows = $dataProvider->getModels();
$page = 0;
foreach ($rows as $key => $val) {
if ($id == $val->id) {
$page = ceil(($key + 1) / $pageSize);
break;
}
}
return $this->redirect(['index', 'page' => $page]);
}
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}