Problem :
I was trying to build auto suggestion select box in my yii2 application.I have downloaded from here https://github.com/kartik-v/yii2-widget-select2 and used select2 widget . below is my code
use kartik\select2\Select2;
use app\models\Contact;
use yii\helpers\ArrayHelper;
$data = ArrayHelper::map(Contact::find()->where(['user_id'=>Yii::$app->user->getId()])->orderBy('email')->asArray()->all(), 'id', 'email');
echo $form->field($model, 'contact_id')->widget(Select2::classname(), [
'data' => $data,
'options' => ['placeholder' => 'Search a contact or add new','multiple' => true],
'pluginOptions' => [
'allowClear' => true,
'tags' => true,
'maximumInputLength' => 1000
],
]);
Here contact is model and give array data of email records like test1@gmail.com,test2@gmail.com but when user search string in dropdownbox it produce output as attachment image
I tried
$this->enableCsrfValidation = false;
in my controller with respective action but no luck, is there any other solution , i have google an hour but there no solution found