showing results for - "kartik select2 ajax"
Benjamín
17 May 2017
1echo $form->field($model, 'city')->widget(Select2::classname(), [
2    'data' => $data,
3    'options' => ['multiple'=>true, 'placeholder' => 'Search for a city ...'],
4    'pluginOptions' => [
5        'allowClear' => true,
6        'minimumInputLength' => 3,
7        'language' => [
8            'errorLoading' => new JsExpression("function () { return 'Waiting for results...'; }"),
9        ],
10        'ajax' => [
11            'url' => $url,
12            'dataType' => 'json',
13            'data' => new JsExpression('function(params) { return {q:params.term}; }')
14        ],
15        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
16        'templateResult' => new JsExpression('function(city) { return city.text; }'),
17        'templateSelection' => new JsExpression('function (city) { return city.text; }'),
18    ],
19]);