Closed Global90 closed 5 years ago
I fix this solution by using jquery trigger function. In below method we can set default value in kartik select2 widget.
$('#id').val(11).trigger('change'); //in val() mention the default value of your select2 hash list
I have changed value in options and it worked for me.
For example:
<?php echo Select2::widget([ 'model' => $modelKani, 'name' => 'Kani', 'id' => 'Kani', 'data' => $data, 'showToggleAll' => false, 'options' => [ 'value' => 'your default value', 'placeholder' => 'insert Tag', 'multiple' => true, 'allowClear' => true, 'minimumInputLength' => 2, ], ]); ?>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
how to in select2 set default value yii2
i use Select2 for Tag.
in insert new post and save tag with Select2 not problem but i need in edit post show Tags List with Select2.