Answer the question
In order to leave comments, you need to log in
How to correctly insert \kartik\select2\Select2 plugin into unclead\multipleinput\MultipleInput plugin in yii2?
Trying to embed \kartik\select2\Select2 plugin into unclead\multipleinput\MultipleInput
Here is instruction from MultipleInput
Here is embed code
<?php
echo $form->field($model, 'items')->widget(MultipleInput::className(), [
'columns' => [
[
'name' => 'slide',
'type' => \kartik\select2\Select2::className(),
'options' => [
'options' => ['placeholder' => 'Поиск ...'],
// 'initValueText' => empty($model->items) ? '' : Item::findOne($model->items)->title,
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 3,
'language' => 'ru',
'ajax' => [
'url' => \yii\helpers\Url::to(['item-list']),
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(item_id) { return item_id.text; }'),
'templateSelection' => new JsExpression('function (item_id) { return item_id.text; }'),
],
],
],
]
])->label(false);
?>
public $items;
public function init()
{
parent::init();
$title = [];
foreach ($this->itemall as $item){
$title[]['slide'] = empty($item['item_id']) ? '' : Item::findOne($item['item_id'])->title;
}
$this->items = $title;
}
public function getItemAll()
{
return self::find()->orderBy(['id' => SORT_ASC])->asArray()->all();
}
'initValueText' => empty($model->items) ? '' : Item::findOne($model->items)->title,
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