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.

Customising the CMS /

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

$searchable_fields - Polulating dropdown with CountryDropdownField

Go to End

4 Posts   1408 Views


Community Member, 48 Posts

3 May 2012 at 9:15am

Firstly, I am only a couple of days into Silverstripe and OOP, having come from a purely procedural background and thrown in the deep end on a project I've been assigned to so please forgive me if I'm overlooking something very basic and/or fundamental. Also in any responses, please assume you are speaking to a 3yr old. Ha.


I have managed to add a drop down labelled "country" to my customer search in the CMS by simply adding :

Member::$searchable_fields = array(
	'ID' => array(
		'field' => 'NumericField',
		'filter' => 'ExactMatchFilter'
	'Country' => array(
		'field' => 'DropdownField'

I need this to take the form of CountryDropdownField.

Is this possible and how do I go about this?

Many thanks in advance.


Community Member, 48 Posts

3 May 2012 at 9:20am

Solved. It was much simpler than I thought.

It needed to read like this:

'Country' => array(
	'field' => 'CountryDropdownField'


Community Member, 48 Posts

3 May 2012 at 11:22am

OK, so I have another question about this. How do I have a blank entry to allow "all countries" to be searched?


Community Member, 24 Posts

23 March 2013 at 3:55am

Edited: 23/03/2013 3:55am

I know this isn't the solution for your exact problem, but yours is the only thread I could find while looking for a fix to a similar problem and thought it may be handy to post my solution here for anyone who may be looking for the same issue as me.

This is how you would add a blank first entry into a CountryDropdownField in the CMS or model admin of a Silverstripe 2.4 site.

$f = parent::getCMSFields();
$cf = new CountryDropdownField("Country", "Country") ;
$f->addFieldToTab("Root.Content.Main", $cf);
return $f ;

Apologies for the slight thread hijack but I'm certain someone will appreciate this post.