K
K
Konstantin Spirin2020-04-22 12:16:27
Yii
Konstantin Spirin, 2020-04-22 12:16:27

Value must be string in yii2 select widget?

When using the select2 widget, when entering data from the database into the widget, it displays a message Value must be a string:
5ea00a2dd928a123435778.png
Codes:
_form.php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use backend\models\Teg;
use yii\helpers\ArrayHelper;



$data = Teg::find()->asArray()->all();

$data = ArrayHelper::getColumn($posts, 'title');

  echo $form->field($model, 'teg')->widget(Select2::classname(), [
    'data' => $data,
  
    'options' => ['placeholder' => 'Выберете тег ...'],
    'pluginOptions' => [
         'multiple' => true
    ],
]);

widget selection looks like this:
5ea00cfe36c01884345388.png

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