我有一个带有dataprovider的gridview,它将两个表作为查询连接起来:
$applicationDataProvider = new ActiveDataProvider([
'query' => Application::find()->with('applicantInfo')
->where(['job_posting_id' => $jobPosting->id,
'deleted_flag' => 0])->orderBy('created_at desc'),
'pagination' => [
'pageSize' => 5
]
]);
这是我的 GridView
:
<?= GridView::widget([
'dataProvider' => $applicationDataProvider,
'filterModel'=>$searchModel,
'columns' => [
'id',
[
'class' => yii\grid\DataColumn::className(),
'headerOptions' => ['style' => 'color:#337ab7'],
'header' => 'სახელი',
'label'=>'name',
'value' => function ($data) {
return $data->applicantInfo->first_name . ' ' . $data->applicantInfo->last_name;
}
],
'applicantInfo.email',
'applicantInfo.phone',
'created_at:date',
[
'class' => 'yii\grid\ActionColumn',
'headerOptions' => ['style' => 'color:#337ab7'],
'template' => '{view}',
'buttons' => [
'view' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('app', 'გახსნა'),
]);
}
],
'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'view') {
$url = '/app-info/?id=' . $model->id;
return $url;
}
}
...
在搜索模型中,我只有电子邮件字段,因为我想gridview只有电子邮件搜索字段。
class ApplicationSearch extends Application
{
public function rules()
{
return [
[['email'], 'safe'],
];
}
但这里没有为电子邮件绘制搜索字段,我如何修复它?
1条答案
按热度按时间unhi4e5o1#
你需要加上
email
属性为ApplicationSearch
要存储筛选器中的值,请执行以下操作:使用此属性进行筛选:
并使用网格中关系的值: