0

I use http://demos.krajee.com/widget-details/select2#usage-tags controller

public function actionTagsForm()
{
    $method = Yii::$app->request->isAjax ? 'renderAjax' : 'render';
    $model = new UserTagsForm();

    return $this->$method('tagsForm', ['model' => $model]);
}

views/layouts/main.php has code modal window

 <?php
yii\bootstrap\Modal::begin([
    'header' => '<div id="modalHeader"></div>',
    'id' => 'modal',
    'size' => 'modal-lg',
    'options' => [

        'tabindex' => false
    ],

]);
echo "<div id='modalContent'></div>";
yii\bootstrap\Modal::end();

?>

view

$data = [
    "red" => "red",
    "green" => "green",
    "blue" => "blue",
    "orange" => "orange",
    "white" => "white",
    "black" => "black",
    "purple" => "purple",
    "cyan" => "cyan",
    "teal" => "teal"
]; ?>

<div class="image-tags-index">

    <?php $form = ActiveForm::begin();?>
    <?php echo $form->field($model, 'image_tags')->widget( Select2::classname(),[

        'data' => $data,

        'options' => ['placeholder' => 'Select a state ...'],
        'pluginOptions' => [
            'allowClear' => true
        ],
    ])->label('Tag Multiple');
 ?>
</div>

error

VM314:2 Uncaught ReferenceError: select2_3f25e3ac is not defined at eval (eval at globalEval (jquery.js:343), :2:56) at eval () at Function.globalEval (jquery.js:343) at domManip (jquery.js:5291) at jQuery.fn.init.append (jquery.js:5431) at jQuery.fn.init. (jquery.js:5525) at access (jquery.js:3614) at jQuery.fn.init.html (jquery.js:5492) at Object. (jquery.js:9436) at fire (jquery.js:3187)

1 Answers1

0

This problem has been solved in the https://github.com/kartik-v/yii2-widget-select2/issues/211

new9xgh
  • 11
  • Please [edit] your answer to expand it. Answers that consist of little more than a link do not meet our standards because links eventually rot. If you can explain what the problem was, a quick summary of what was fixed, and what version you need to get the fix, then this would be a good answer. – Cody Gray - on strike Sep 17 '17 at 15:27