Closed lucadima15 closed 5 years ago
Hi all.
Usually placeholder works fine. But if I also use ajax to load options, placeholder doesn't display anything.
Code totally working:
<?= $form->field($model, 'idCity', [ 'options' => [ 'style' => 'margin-top: 10px;' ], ])->widget(Select2::classname(), [ 'data' => $cities, 'options' => ['placeholder' => 'Select city ...'], 'pluginOptions' => [ 'allowClear' => true ] ]);?>
Code working in ajax loading, but not displaying placeholder:
<?= $form->field($model, 'idCity', [ 'options' => [ 'style' => 'margin-top: 10px;' ], ]) ->widget(Select2::classname(), [ 'options' => ['placeholder' => 'Select city ...'], 'pluginOptions' => [ 'allowClear' => true, 'minimumInputLength' => 3, 'ajax' => [ 'url' => Url::to(['city/search']), 'dataType' => 'json', 'data' => new JsExpression("function(params) { return {q:params.term} }"), ], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(city) { return city.name; }'), 'templateSelection' => new JsExpression('function (city) { return city.name; }'), ] ]); ?>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi all.
Usually placeholder works fine. But if I also use ajax to load options, placeholder doesn't display anything.
Code totally working:
Code working in ajax loading, but not displaying placeholder: