0
在观看/索引文件,其中示出了模型的所有i的数据使用为什么我的过滤器arrayhelper没有显示数据库yii2的值?
'filter'=>ArrayHelper::map(Mobile::find()->asArray()->all(),'id', 'mobile'),
它工作忠实地但不显示值。它只有一些空的领域。
这里是我的看法/指数代码:
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper ;
use app\models\Mobile;
/* @var $this yii\web\View */
/* @var $searchModel app\models\MobileSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Mobiles';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mobile-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Mobile', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'id',
[
'attribute'=>'id',
'value'=>'id',
//'filter'=>array("1"=>"open","2"=>"in progress","3"=>"closed")
'filter'=>ArrayHelper::map(Mobile::find()->asArray()->all(),'id', 'mobile'),
],
'sim_num',
'network',
'twog_network',
'threeg_network',
// 'fourg_network',
// 'technology',
// 'gps',
// 'gateway_connection',
// 'super_id',
// 'camera',
// 'resolusion_camera',
// 'automatic_focus',
// 'camera_flash',
// 'video:ntext',
// 'camera_others:ntext',
// 'camera_selfie:ntext',
// 'username',
// 'body:ntext',
// 'title:ntext',
// 'state',
// 'imageFile',
// 'size',
// 'weight',
// 'inner_memory',
// 'screen_size',
// 'screen_type',
// 'wifi_desc',
// 'bluetooth',
// 'batery',
// 'bady_struct',
// 'process',
// 'other:ntext',
// 'os',
// 'gesture',
// 'items',
// 'speaker',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
其中
<?php
'attribute'=>'id',
'value'=>'id',
'filter'=>ArrayHelper::map(Mobile::find()->asArray()->all(),'id', 'mobile'),
],
?>
我重复它显示的字段数量和搜索正确的,当点击每一个领域和一个小问题它不显示值...
在检查网站我们h AVE:
<option value="2"></option>
,我想表演 '2' 选项标签之间..
请帮助我。
是选项,过滤器,应显示为移动而不是ID值的值。2是ID或价值移动的价值? – scaisEdge
2是id的值 – areff
它对我来说并不是很清楚,但是如果你想在选项中加上id值,也许这足以用这种方式进行映射:ArrayHelper :: map(Mobile :: find() - > asArray( ) - > all(),'id','id'); – Masiorama