Kartik Select2

In Kartik select2 is it posible to add a checkbox above the search area?

For something like a checkbox with "Exact search".

Thx.

Kartik use Select2 and therefore the yii2 widget can do what the original widget can do.

You should consult Select2 documentation.

https://select2.gith…es.html#matcher

Custom Matcher example is almost the one you are looking for. You need to adapt it to you specific need.

Just some consideration…

If you need exact match, there is no reason to use a select2 filtering, you do not get anything in plus.

Maybe I’m wrong and didn’t consider some particular scenario.

Probably the custom match of the example which match entries that begin with what you type is the best for you.

About the checkbox that switch between filtering method are just few line of javascript that change matcher property of slect2 when check/uncheck the flag.

Never tried to change it on the fly but it should work.

Thx Roberto

I will look into it.