我试图在Gridview中设置Kartik Editable。我尝试使用可编辑:: INPUT_DROPDOWN_LIST ,其选项取决于来自其他列的数据
我在ID Ket.
列中设置了可编辑状态,下拉列表的选项取决于列Kode Jenis
的值。
['class' => 'kartik\grid\EditableColumn',
'attribute' => 'id_keterangan_tambahan',
'vAlign' => 'middle',
'headerOptions' => ['class' => 'kv-sticky-column'],
'contentOptions' => ['class' => 'kv-sticky-column'],
'editableOptions' => [
'data' =>
[
function ($model, $key, $index, $widget) {
$kode_jenis = $model->kode_jenis;
switch ($kode_jenis) {
case "07":
$t = [
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => '6'
];
break;
case "08":
$t = [
1 => '1',
2 => '2',
3 => '3',
4 => '4',
];
break;
default:
$t = [
0 => '0',
];
break;
}
return $t;
},
],
'options' => ['class' => 'form-control', 'prompt' => 'Select ID...'],
'displayValueConfig' => [
'0' => '0 <i class="glyphicon glyphicon-ok" style="color: green"></i>',
'9' => '- <i class="glyphicon glyphicon-remove" style="color: #ff0000"></i>',
],
'header' => 'ID Keterangan Tambahan',
'size' => 'md',
'inputType' => Editable::INPUT_DROPDOWN_LIST,
'widgetClass' => 'kartik\datecontrol\DateControl',
'options' => [
'type' => Editable::INPUT_DROPDOWN_LIST,
'options' => [
'pluginOptions' => [
'autoclose' => true
]
]
]
],
],
[
'attribute' => 'kode_jenis',
'value' => function($data) {
return $data->kode_jenis;
},
'hAlign' => 'center',
'width' => '175px',
],
下拉列表仅显示Kode Jenis 07 or 08
的选项。
但是我得到了这样的错误
htmlspecialchars()期望参数1为字符串,给定对象