2016-11-22 8 views
0

私はindex.phpを変更してidの代わりに名前を表示しました。YII2 - index.phpの列フィルタは機能しません

これは私の注文/

<?php 

use yii\helpers\Html; 
use yii\grid\GridView; 
use yii\widgets\Pjax; 
use yii\helpers\ArrayHelper; 
use frontend\models\Statuses; 


$this->title = Yii::t('app', 'Ordini'); 
$this->params['breadcrumbs'][] = $this->title; 
$user = Yii::$app->user->identity; 
?> 
<div class="orders-index"> 

    <h1><?= Html::encode($this->title) ?></h1> 

    <p> 
     <?php 
      if ($user->role == 10 || $user->role > 40) 
       echo Html::a(Yii::t('app', 'Nuovo'), ['create'], ['class' => 'btn btn-success']); 
     ?> 
    </p> 
<?php Pjax::begin(); ?> 

<?= GridView::widget([ 
     'dataProvider' => $dataProvider, 
     'filterModel' => $searchModel, 
     'columns' => [ 
      ['class' => 'yii\grid\SerialColumn'], 

      ['attribute'=>'customer_id', 'value'=>'CustomersName',], 
      ['attribute'=>'product_id', 'value'=>'ProductsName',], 
      'date', 
      [ 
       'attribute'=>'status_id', 
       'value'=>'StatusesName', 
       'filter' => Html::activeDropDownList($searchModel, 'status_id', ArrayHelper::map(Statuses::find()->asArray()->all(), 'id', 'name'),['class'=>'form-control','prompt' => 'Select Category']), 
      ], 

      ['class' => 'yii\grid\ActionColumn'], 
     ], 
    ]); ?> 
<?php Pjax::end(); ?></div> 

フィルターが動作しませんindex.phpのです。私はドロップダウンで試してみました。 どこが失敗するかを確認する方法がわかりません!

OrdersSearch?モデルやコントローラーで?

ありがとうございました

答えて

0

ドロップダウンフィールドにコード全体を指定する必要はありません。これで十分です:

+0

フィルターは機能しませんでした – GMazzacua

+0

質問に '$ searchModel'の後ろにあるクラスのコードを追加してください。 – Bizley

+0

OrdersSearch?ここでは、http://pastebin.com/VLLzXf8cとここでordersearch http://pastebin.com/pSd64qmC – GMazzacua

関連する問題