A
A
Alexander Laikov2020-12-13 18:29:18
Yii
Alexander Laikov, 2020-12-13 18:29:18

Why is Select2 kartik not showing input fields and hidden?

Good afternoon!
I connected the Select2 plugin from kartik and as a result there is no form for selection.

<?php


use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin(); ?>

var_dump($data);

echo $form->field($model, 'subscriber')->widget(Select2::classname(), [
    'data' => $data,
    'options' => [
    	'placeholder' => 'Select a state ...'
    ],
    'pluginOptions' => [
        'allowClear' => true
    ],
]);

ActiveForm::end(); 

?>


As a result, we get the following result:
<form id="w0" action="/appeal/create" method="post">
<input type="hidden" name="_csrf" value="sAiGBmoczOEC3d_0ltMF0oiQ-CajulQCw5yJFOvXld3SX8JWBiu41U2NuoTD6miX6efNEMLvDVqLsc5ApbXZrA==">array(4) {
  [1]=&gt;
  string(1) "1"
  [2]=&gt;
  string(1) "2"
  [3]=&gt;
  string(1) "3"
  [4]=&gt;
  string(1) "4"
}
<div class="form-group field-appealform-subscriber">
<label class="control-label" for="appealform-subscriber">Subscriber</label>
<select id="appealform-subscriber" class="form-control select2-hidden-accessible" name="AppealForm[subscriber]" data-s2-options="s2options_d6851687" data-krajee-select2="select2_9f933b6f" style="width: 1px; height: 1px; visibility: hidden;" data-select2-id="select2-data-appealform-subscriber" tabindex="-1" aria-hidden="true">
<option value="" data-select2-id="select2-data-2-gica">Select a state ...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><span class="select2 select2-container select2-container--krajee" dir="ltr" data-select2-id="select2-data-1-otl2" style="width: 100%;"><span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-disabled="false" aria-labelledby="select2-appealform-subscriber-container"><span class="select2-selection__rendered" id="select2-appealform-subscriber-container" role="textbox" aria-readonly="true"><span class="select2-selection__placeholder">Select a state ...</span></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>

<div class="help-block"></div>
</div></form>

5fd633125e082885529379.png

It can be seen that everything is being formed, but there is no Select2 field itself.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question