Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Search-equipped DropdownField


Go to End


4 Posts   1677 Views

Avatar
moniuch

Community Member, 11 Posts

11 April 2014 at 10:02am

While messing around in DevTools trying to see how DropdownFields are built, I found out a hidden part with CSS class chzn-search. When I revealed it, a nice filtering div appeared, fully functional. Something I would like to deliver on the admin side. How can I turn it on in the DropdownField declaration? I can't seem to find a field subclass that would turn it on.

Avatar
dylangrech92

Community Member, 17 Posts

13 April 2014 at 11:34pm

I'm not sure this is what you found however uncle cheese has a nice tutorial on how to have a dropdown with search amongst other nice field types. Check it out at: http://www.leftandmain.com/?s=bootstrap&cat=4&link=1

Avatar
martimiz

Forum Moderator, 1391 Posts

14 April 2014 at 1:32am

If it's the searchbox within the dropdown you're referring to, it should appear if the number of options exceeds 20, as that is how selectboxes in the cms are instantiated by default (using the 'chosen' library). See LeftAndMain.js #46 : disable_search_threshold: 20

https://github.com/silverstripe/silverstripe-framework/blob/3.1/admin/javascript/LeftAndMain.js

Avatar
moniuch

Community Member, 11 Posts

14 April 2014 at 5:57am

Edited: 14/04/2014 9:01am

True, when the search panel did appear when I increased the amount of records. Thanks for that.
The filter however appears to use "starts with" filtering. Is there a way to change it to "contains" mode?

Oh wait! It does the "contains" search, but only among original values, as long as the are not altered by custom function (I'm using DropdownSummary to return customized label)