2017-10-06 3 views
0

Auf der kartik gridview i wie unten Filter mit ausgewählten 2-Typ hinzufügen möchten:filterWidgetOptions funktioniert nicht (yii2)

[ 
       'attribute' => 'product_id', 
       'value' => function ($model) { 
       return $model->product->name; 
       }, 
       'filterType'=>GridView::FILTER_SELECT2, 
       'filter'=>ArrayHelper::map(\app\models\ProductWord::find()->asArray()->all(), 'name', 'name'), 
       'filterWidgetOptions'=>[ 
        'pluginOptions'=>['allowClear'=>true, 'minimuminputLength' => 3], 
       ], 
       'filterInputOptions'=>['placeholder'=>'Any Product', 'multiple' => true ], 
       'group'=>true, // enable grouping 
       'label' => 'Product', 
       'headerOptions' => 
        ['style'=>'max-width: 70%; font-size: 12px;overflow: auto; word-wrap: break-word;'], 
       'contentOptions' => 
        ['style'=>'max-width: 70%; font-size: 12px;overflow: auto; word-wrap: break-word;'], 
], 

aber das Ergebnis ist filterWidgetOptions funktioniert nicht. Ich füge allowclear und minimuminputLength hinzu, aber es funktioniert nicht. Was mache ich falsch mit diesem Code?

danken Ihnen

Antwort

0

Seit Suchmodell für id sieht eine Suche zu machen, Sie

id

zu

Name

Karte sollte
'filter'=>ArrayHelper::map(\app\models\ProductWord::find()->asArray()->all(), 'id', 'name'), 

Ändern Sie auch Ihre Wert wie unten. Sie sollten Ihr Modell verwenden, um Werte zu erhalten.

'value' => function ($model) { 
     return $model->product->name; 
    },