Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2. Kartik Select2 widget width

My Select2 control is inside column with bootstrap class 'col-sm-3'. Also it is attached to form field. But width does not want to be 100% of parent column. If I make browser window smaller (after columns auto-rearangment) Select2 follows width of the parent column. Also if I specify width in px it changes the width. What could be a problem? Same story for form->field->textInput. Also I found the field width does not follow parent column width if the form is inline.

<?= $form->field($model, 'categories')->widget(Select2::className(), [
                'data' => Category::availableCategories(),
                'model' => $model,
                'attribute' => 'categories',
                'theme' => Select2::THEME_KRAJEE,
                'size' => Select2::MEDIUM,
                'showToggleAll' => false,
                'language' => 'en',
                'options' => ['placeholder' => 'Select a category...', 'id' => 'myselect'],
                'pluginOptions' => [
                    'allowClear' => true,
                    'multiple' => true,
                    'width' => '200px',
                    ],
                ])
            ?>
like image 334
Dmytro Avatar asked Oct 15 '25 15:10

Dmytro


1 Answers

I had inline layout in my form. This was a problem.

like image 144
Dmytro Avatar answered Oct 17 '25 08:10

Dmytro