Answer the question
In order to leave comments, you need to log in
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:
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
],
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question