jqueryyii2jquery-select2kartik-v

Problem when using select2 in a dynamic form


I'm using extensions dynamicform and select2 together in one form.:

wbraganca\dynamicform\DynamicFormWidget 
kartik\select2\Select2

It works fine at first, but when adding another field, it just looks like loading:

enter image description here

How do i see what is causing the problem?

The code of the fields:

*$data has approximately 2000 records*

<?php

    $data = ArrayHelper::map(Alimento::find()->orderBy("alimento ASC")->all(), 'id', 'alimento');

    echo $form->field($modelItemreceita, "[{$i}]alimento_id")->widget(Select2::classname(), [
         'data' => $data,
         'name' => "[{$i}]alimento_id",
         'language' => 'pt-br',
         'options' => ['placeholder' => '-- Selecione o ingrediente --'],
    ]);
?>

<?= $form->field($modelItemreceita, "[{$i}]qtde")->textInput(['type' => 'number', 'maxlength' => true]) ?>

Solution

  • I found a post with the same problem and among the possible solutions, this one worked for me:

    In composer.json changing wbraganca/yii2-dynamicform to dev-master worked for me. kartik-v/yii2-widget-select2 version is 2.0.0