I have a problem regarding insertion of data after explode. In this gridview column, I throw function in value like this:
[
'attribute' => 'CONNECTOR_ACTION',
'value' => function($model){
$apps = \app\models\APPLICATION::find()
->where(['ID' => $model->ID_APPLICATION])
->one();
$options = $apps['CONNECTOR_PARAM'];
$optionsArr = explode(', ', $options);
return Html::activeDropDownList($model, 'CONNECTOR_ACTION', $optionsArr, ['class'=>'form-control', 'disabled' => true]);
},
'format' => 'raw'
],
And in HTML view like this:
<td>
<select id="requestapplication-connector_action" class="form-control" name="REQUESTAPPLICATION[CONNECTOR_ACTION]" disabled>
<option value="0">create</option>
<option value="1">addrole</option>
<option value="2">defaultrole</option>
<option value="3">removerole</option>
<option value="4" selected>disable</option>
<option value="5">enable</option>
<option value="6">setpassword</option>
</select>
</td>
If I want to change dropdown like this:
<td>
<select id="requestapplication-connector_action" class="form-control" name="REQUESTAPPLICATION[CONNECTOR_ACTION]" disabled>
<option value="create">create</option>
<option value="addrole">addrole</option>
<option value="defaultrole">defaultrole</option>
<option value="removerole">removerole</option>
<option value="disable" selected>disable</option>
<option value="enable">enable</option>
<option value="6">setpassword</option>
</select>
</td>
How do I do that?
This is because the keys of
$optionsArr
are 0-6 instead of the values. To combine it set the keys the same as the values.And then use
$combined
inHtml::activeDropdownList()