Creating Search With Drop Down

Hi,

Lets say I have some array and as I type something in search it shows only those array values that contain my entry. I cant figure out how to do it and cant find a good article about it. I would appreciate if you would give me some links or give some example.

Thanks

Hello,

Here’s a working example what you want.

Now I want to know to how to do it…

http://demos.krajee.com/grid-demo

You can make your code like this :

<?php echo $form->dropDownList($model,‘field_name’,CHtml::listData($data,‘id’,‘value’),array(‘empty’ => ‘All’)); ?>

CHtml is sooo Yii1 or isn’t it…

Still need a better example for this to work… Where to place this code view/invoice/_search.php ?

And will it still work with my code added in models/invoiceSeach where it looks for a customer when typing in the Searchfield.


$query->andFilterWhere(['like', 'customers.customername', $this->customer]);

(In my model invoice I’v allready added the customer relation)


public function getCustomer()

    {

        return $this->hasOne(customers::className(), ['id' => 'customer_id']);

    }

So a step bij step Yii2 tutorial would be real nice!

You have to use a widget, like select2 or selectize.

Than it’s as easy as a regular dropdown

Yes!! those, did you get them to work in the search box?

If you did plaese provide the samples!

Where to add the code in which controllers/files!!