Closed ma6e4kaa closed 2 years ago
I have found the solution:
It should be written in $beforeRow like this:
echo GridView::widget([
'dataProvider' => $provider,
'filterModel' => $searchModel,
'beforeRow' => function($model) {
$model->contractor_id = json_decode($model->contractor_id,TRUE);}
'pjax' => true,
'options' => ['style' => 'font-size:12px;'],
'columns' => [
['class' => 'kartik\grid\EditableColumn',
'attribute' => 'code',
'width' => '200px',
'editableOptions'=>[
'asPopover' => false,
],
],
['class' => 'kartik\grid\EditableColumn',
'attribute' => 'oks',
'editableOptions'=>[
'asPopover' => false,
],
],
['class' => 'kartik\grid\EditableColumn',
'attribute' => 'contractor_id',
'editableOptions'=>[
'inputType'=> Editable::INPUT_SELECT2,
'options' => [
'data'=> ArrayHelper::map($contractor_id, 'id', 'contractor'),
'options' => [
'multiple' => true,
],
],
'asPopover' => false,
],
],
],
]);
I want to use multiple select2, it works actually, but only after choosing the value from the dropdown list.
If I set multiple false, it works:
But if I use multiple, at first it will be like this:
How should I submit this value for input with json_decode?
Here's my code GridView:
Controller: