Yii2: How to disabled or readonly a Select2 widget?

Keywords´╝Ü php html yii2 jquery-select2 disabled-input


I use a widget based on select2.github.io and I need it to be readonly so the user can see a default select option but it can't be changed and I think this widget doesn't have this option.

Is there a general solution for any Select2 widget?

$form->field($model, 'id_color')->widget(Select2::classname(), [
    'items' => ['1' => 'blue', '2' => 'red', '3' => 'yellow']