1

I'm trying to set Kartik Editable in my Gridview. I'm trying to use Editable::INPUT_DROPDOWN_LIST that has options depends data from another column

This is the viewenter image description here

I set the Editable in column ID Ket., and the options of dropdown list depend on value from column Kode Jenis.

This is my code in my grid

            ['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',
        ],

The dropdown only show options if the Kode Jenis 07 or 08.

But I got error like this

htmlspecialchars() expects parameter 1 to be string, object given

Does my code right? If it's not, how do I can do that?

Community
  • 1
  • 1
Blackjack
  • 1,016
  • 1
  • 20
  • 51

0 Answers0