I want use selectizeTextInput widget in yii2 that search with ajax and remote
search but when load query in page,that use selectize widget,jump the page
and dont allow me to complete the word and by entering per letter in word and
query handling jump the page.
how to solve this problem?
this is my code that use selectize text input for select and create tags with ajax search in yii2 project.
in view I have form and use Selectize text input :
<?= $form->field($model, 'tags')->widget(
SelectizeTextInput::className(),
[
'loadUrl' => \Yii::$app->urlManager->createUrl('tag/manage/find-tag'),
'options' => ['class' => 'form-control'],
'clientOptions' => [
'create' => true,
'options' => $items,
'items' =>$model->getTagsAsArray(),
'valueField' => 'title',
'labelField' => 'title',
'searchField' => ['title'],
'plugins' => ['remove_button'],
],
]
)
?>
in controller I have one action that query handling with per letter that enter in selectize :
public function actionFindTag()
{
$tags = Tag::find()->andWhere(['like', 'title', urldecode($_GET['query'])])->all();
echo '[' . Json::encode(
[
Utility::makeReadyForSelectize($tags, 'title', 'title'),
]
) . ']';
exit;
}