Kartik / Krajee Select2 not disabled

The Select option for Disabled does not disable the item. The user can still click on the Select2 element, and a window with the parameters will open. Here is a disabled control that was opened by clicking on the text, not the down arrow button.

Disabled management:

Here is my code:

<?= $form->field($model, 'billing_currency_id')->widget(Select2::className(), [
'data' => BillingCurrency::listIdCodes('','',true),
'disabled' => true,
'options' => ['disabled' => true,],
'pluginOptions'=>[
    'allowClear'=>false,
    'dropdownAutoWidth'=>true,
    'disabled' => true,
], ]); ?>

When you click on the button with the down arrow, the control is closed, but clicking on the text area of ​​the control opens the options window.

UPDATE Found my own error - see the answer below.

+4
source share
2 answers

- - JS- , Select2, . . Select2, , . . Select2 , , UNLESS, . ( .)

$(document).on('focus', '.select2', function() {
    var elSelect = $(this).siblings('select');
    if (elSelect.is('[disabled]')==false) {
        elSelect.select2('open');
    }
});
+2

( ):

Select2 <select>. Select2 : true, .

Kartik, 'disabled' => true options :

'options' => ['disabled' => true],

, , .

+1

Source: https://habr.com/ru/post/1625248/


All Articles