Closed ma6e4kaa closed 1 year 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:
![image](https://user-images.githubusercontent.com/81535725/182870491-3ec2feda-1ed8-4ae0-b81b-843038b0f720.png)
But if I use multiple, at first it will be like this:
![image](https://user-images.githubusercontent.com/81535725/182871034-cebddbd4-2021-433d-958e-7b7bea5389f7.png)
How should I submit this value for input with json_decode?
Here's my code GridView:
Controller: