1$form->field($model, 'attribute')->widget(\kartik\select2\Select2::classname(), [
2 'data' => \yii\helpers\ArrayHelper::map(Model::find()->all(), 'id', 'username'),
3 'options' => ['placeholder' => 'Tanlang', 'multiple' => false, 'required' => true],
4 'theme' => \kartik\select2\Select2::THEME_KRAJEE,
5 'size' => 'xs',
1use kartik\select2\Select2;
2
3// Normal select with ActiveForm & model
4echo $form->field($model, 'state_1')->widget(Select2::classname(), [
5 'data' => $data,
6 'language' => 'de',
7 'options' => ['placeholder' => 'Select a state ...'],
8 'pluginOptions' => [
9 'allowClear' => true
10 ],
11]);
12
13// Multiple select without model
14echo Select2::widget([
15 'name' => 'state_2',
16 'value' => '',
17 'data' => $data,
18 'options' => ['multiple' => true, 'placeholder' => 'Select states ...']
19]);