5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 354 Views |
-
$searchable_fields - Polulating dropdown with CountryDropdownField

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.
Anyway.
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'
),
'FirstName',
'Surname',
'Email',
'Client',
'City',
'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.
-
Re: $searchable_fields - Polulating dropdown with CountryDropdownField

3 May 2012 at 9:20am
Solved. It was much simpler than I thought.
It needed to read like this:
.....
'Country' => array(
'field' => 'CountryDropdownField'
)
.... -
Re: $searchable_fields - Polulating dropdown with CountryDropdownField

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?
-
Re: $searchable_fields - Polulating dropdown with CountryDropdownField

23 March 2013 at 3:55am Last edited: 23 March 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") ;
$cf->setHasEmptyDefault(1);
$f->addFieldToTab("Root.Content.Main", $cf);
return $f ;Apologies for the slight thread hijack but I'm certain someone will appreciate this post.
| 354 Views | ||
|
Page:
1
|
Go to Top |


