class MySearchModel extends Model
{
// ...
public function search()
{
$query = MyModel::find();
if ($this->validate()) {
$query->filterWhere($this->getAttributes());
}
return new ActiveDataProvider(['query' => $query]);
}
}
View search.php
echo GridView::widget([
'dataProvider' => $dataProvider, // instance of [[ActiveDataProvider]]
'filterModel' => $filterModel, // instance of [[MySearchModel]]
// ...
]);
Added
strongsquirrel\actions\SearchAction
.Usage: Controller
SiteController.php
Model
MySearchModel.php
View
search.php