php - Autocomplete in yii2 -


In Yii2 I want one of my input fields to be auto-complete, when the user starts typing Please. Below is my code which joo autocomplete .

  & lt ;? Php $ items = ArrayHelper :: Map (Company :: Search () - & gt; All (), 'c_id', 'name'); Copy autocomplete :: widget (['model' = & gt; $ model, 'attribute' = & gt; 'company', 'customer option' => ['source' => $ item,] ,]) ;; & Gt;   

This is not working. When I printed my array, I

  Aare ([1] => abc [2] => CIG [4] => pqr)   

I had to work while setting it manually

  $ items = ['abc', 'xyz' 'pqr'];   

Could it be that my c_id's order has not been given? But I have to submit the c_id value! Any ideas how to fix this?

This can be solved with the help of a hidden field input. anyone!

  & lt ;? Php use yii \ web \ JsExpression; $ Data = company :: search () - & gt; (['Name as name', 'name as labels', 'cid as id']) - & gt; AsArray () - & gt; all (); Copy autocomplete :: widget (['name' = & gt; 'company', 'id' => ddd ',' client option '= & gt; [' source '= & gt; $ data, 'AutoFill' = & gt;, 'Minnamp' = & gt; '4', 'Selection' => New JS Express ("Function (Event, UI) {$ ('# User-Company'). Val ( Ui.item.id);} ")],]); ? & Gt; & Lt ;? = Html :: ActiveHideInput ($ Model, 'Company')? & Gt;    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -