Answer the question
In order to leave comments, you need to log in
Why does Widget Select2 duplicate select?
kartik\select2 widget for yii2
$form->field($m, 'TourSearchFilter[country_from_id]')->widget(Select2::classname(), [
'options' => ['placeholder' => 'Из любой страны','class' => 'select user-form firm-form', 'id'=>'cat-id-id'],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 2,
'language' => 'ru',
'ajax' => [
'url' => $url,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(country) { return country.text; }'),
'templateSelection' => new JsExpression('function (country) { return country.text; }'),
],
])->label(false);
Answer the question
In order to leave comments, you need to log in
I will assume that in addition to rendering the select2 widget by the form generator, you also call select2 in js.
That is, the Select2 package at the output gives you a ready-made widget (and it consists of a regular hidden select and a set of spans), and in js you attach the select2 function to the same hidden select.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question