【发布时间】:2018-09-01 10:15:12
【问题描述】:
我尝试使用 Select2 Kartik 过滤列,但没有出现任何内容。 select2 没有完全加载。将显示标签显示为无。
/views/user/index.php
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
],
'name',
/*
This code not works :(
*/
[
'attribute' => 'identification_type',
'value'=> function($model){
return Yii::t('app', TYPE_ID[$model->identification_type]);
},
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'identification_type',
'data' => Arrai::t('person',TYPE_ID),
'theme' => Select2::THEME_BOOTSTRAP,
'hideSearch' => true,
'options' => [
'placeholder' => Yii::t('person', 'Identification type'),
]),
],
/*
This code works!
*/
[
'attribute' => 'identification_type',
'filter' => Arrai::t('app', TYPE_ID),
'value'=> function($model){
return Yii::t('app', TYPE_ID[$model->identification_type]);
},
'filterInputOptions' => [
'class' => 'selectpicker',
'data-style'=>"btn btn-primary btn-round",
'title'=> "Sin seleccion",
],
],
// other columns
]
以下是结果html:
Result HTML
<div class="form-group is-empty">
<select id="personsearch-identification_type" class="form-control" name="PersonSearch[identification_type]"
data-s2-options="s2options_6cc131ae"
data-krajee-select2="select2_0ed9734f"
style="display:none">
<option value="">Tipo de identificación</option>
<option value="CC">Citizenship card</option>
<option value="CE">Foreigner ID</option>
<option value="PAS">Passport</option>
<option value="NIT">NIT</option>
</select>
<span class="material-input"></span></div>
在此结果中,需要 <span> 标记来显示 Select2。但它没有出现。
【问题讨论】:
-
Arrai::t('person',TYPE_ID)输出什么?是数组还是文本
标签: php gridview yii2 jquery-select2